Skip to content

Instantly share code, notes, and snippets.

@danielkelshaw
Last active September 28, 2020 17:00
Show Gist options
  • Save danielkelshaw/04c40403101e2e14ffd6f6750529f713 to your computer and use it in GitHub Desktop.
Save danielkelshaw/04c40403101e2e14ffd6f6750529f713 to your computer and use it in GitHub Desktop.

Python | IDE Guide

When developing Python you need an editor to work within. There are many different options but the one I would recommend is PyCharm.

As a student you can get access to PyCharm Professional, otherwise you can just download the standard PyCharm Community Edition - once you've done this you're ready to start.

Setting up PyCharm

When you open PyCharm you can point to a folder and have it open as a project - alternatively you can open it with the commandline using:

$ charm path/to/project

Once you've got the code loaded up you need to configure a few things. First of all you need to let PyCharm know which Python executable to run. Since we will be using virtual environments it is important to select the right one.

Python Interpreter

If you go to settings (CTRL+ALT+S | CMD+,) and navigate to: Project/Python Interpreter you should be able to click the cog in the top right and add.

This will open up a panel which gives the option of using virtualenv or conda environments (among a variety of other options). If you have not yet built a virtual environment you can have PyCharm create a new one for you, or if you have already built one, you can select "Existing Environment" and point the filepath to the Python executable in the virtual environment folder.

PyCharm will now know which Python to use when running your code.

Docstring Format

Once again in settings, navigate to: Tools/Python Integrated Tools. Here you want to change the Docstring Format to NumPy - this is easier to work with when you're writing documentation.

Adding Guides

In an attempt to keep code nice and tidy its nice to have vertical guides set at a certain number of characters - this stops you from writing super long lines of code.

The Python style guides recommend 80chars but allowing upto 100chars where it improves legibilty.

You can add these lines in by going to: Settings/Editor/Code Style/Python/Wrapping and Braces. Here you can write 80,100 in the visual guides box.

Visuals

In settings navigate to Plugins. Here you can search for a variety of extentions including themes. At the moment I'm using the theme "Monokai Pro Theme". Once this is installed you can go through various options in Settings/Appearance & Behaviour/Appearance - there will be a dropdown menu at the top which you can use to customise how PyCharm looks.

At the moment I'm enjoying the "Filter Ristretto" theme from "Monokai Pro".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment