Using Python with PyCharm

Note: This document will be updated as I continue to learn how to use PyCharm more effectively.

Python is an interpreted language, which, simply put, means it comes with the “batteries included”. It can transform your text and run it on the fly.

PyCharm is an Integrated Development Environment (IDE), which can make your life easier when writing python code by doing such things as auto-completing brackets, indentations and quotation marks for you as you type..

Stage 1: Install Python and PyCharm

Download and install the latest Python 3 application from here.

For Windows users, make sure to tick the box that says to add python to the PATH, as this enables the ability to use Python from a terminal. Then choose Install Now.

Download and install the latest PyCharm application from here. Accept the defaults when installing.

Stage 2: New Project and Orientation

Launch and name a new project.

On your project page, you will notice the side and bottom panel menus.

The switch to toggle these on and off is in the bottom left-hand corner.

On the bottom right you can see the interpreter you are using, and by clicking on it you have the option to edit the interpreter settings.

Displayed in the middle of the application screen are a few keyboard command shortcuts. Each operating system will have its relative commands. So to expand my project folder on the top-left, you can use the mouse or these keyboard shortcuts.

Create a new Python file by right-clicking on the project folder and selecting New > Python File, and name it.

Create the obligatory “hello, world” first program.

You will notice that the IDE helps out by providing some autocomplete options.

Now you will notice that your Run button is greyed out at the top. The program currently does not have a run configuration. Once you run it once, the Run button will be available at the top to Run this program going forward.

For the quickest way to run this program, try the following options:

  • Right-click on it and choose Run.
  • Use the Run menu at the top of the screen and choose run.

When you run your code it will appear in a run box down below.

The position of all of these areas can be changed. Just click and drag the name to the side you want to have it.

Stage 3: Settings, Appearance and Plugins

Go to File > Settings and select Plugins.

From the MarketPlace, install Presentation Assistant. It is a plugin that will assist with learning the keyboard shortcuts.

Here you can then edit the Presentation Assistant settings.

Some keyboard shortcuts examples:

Shortcut | Action

Search Everywhere | Double Shift

Quickly find any file, action, class, symbol, tool window, or setting in PyCharm, in your project, and in the current Git repository.

Extend Selection | Ctrl+W

Shrink Selection | Ctrl+Shift+W

Increase or decrease the scope of selection according to specific code constructs.

To edit the overall IDE appearance, go to File > Settings > Appearance. Here you can change the theme and IDE fonts (not the code editor fonts).

To change the code editor font, go to File > Settings > Editor > Font.

SUMMARY

Thank you for visiting my tutorial page. For more tutorials, be sure to check IMCK Training for the latest updates.

1st & 2nd line IT training services.