Working with PyCharm

Project management

Create a new project in PyCharm

  1. In the File menu select New Project…,
  2. On the left side select the Python framework you want to use,
  3. Enter the name for your project to the end of the Location path,
  4. If you have selected a framework that asks for more information
    1. Click the More Settings link and enter the additional values,
    2. Click the Create button,
    3. PyCharm generates folders for your project and application,
    4. When PyCharm asks you about compatibility inspection, enable it, to make sure your code is compatible with future versions of Python.
    5. PyCharm will enable Code compatibility inspection. Click OK to save the setting.
    6. PyCharm will still set your project interpreter to 2.6, so set it to 2.7. In the PyCharm menu select Preferences…,
    7. On the left side select Project:…, Project Interpreter,
    8. In the Project Interpreter drop-down select 2.7 and click the OK button.

Delete a project in PyCharm

The PyCharm project explorer does not have a delete option. To delete a PyCharm project

  1. Open the project location in Finder,
  2. Move the project folder to the Trash,
  3. The PyCharm project explorer window will reflect the change.

Shortcuts, tips, and tricks

 Auto generate

Auto generate functions, classes, attributes

  1. Enter the name of the undefined element where you want to use it,
  2. Click the light bulb, or press ⌥⏎ (Alt-Enter) to pop up the Intention Action alert,
  3. Select the action to generate the definition.

Auto generate fields for classes

  1. Enter the __init__ function of the class with the field names,
  2. Place the cursor on the field you want to generate the definition for,
  3. Click the light bulb, or press ⌥⏎ (Alt-Enter) to pop up the Intention Action alert,
  4. Select Add field ‘…’ to class …,
  5. Press Enter to select the option,
  6. Press Enter at the end of the new line to move the cursor to the next line, otherwise, the Intention Action alert does not pop up when you press ⌥⏎ (Alt-Enter)

 

Code completion

  • Press Ctrl-Space to complete the name of the element.
  • Press Ctrl-Space twice to complete the name of any class, even if it is not yet imported. The import statement will be automatically added.

Quick documentation

To get a short documentation on an element under the cursor, press F1. (By default on a Macintosh you need to press fn-F1, because the F1 button is programmed to adjust the brightness.)

For more information

Auto completing code, see https://www.jetbrains.com/help/pycharm/auto-completing-code.html

Keyboard shortcuts
https://www.jetbrains.com/help/pycharm/keyboard-shortcuts-and-mouse-reference.html

Leave a Reply