Python Tutorial Part Two: Coding Tools

by Simon Bluck

Editors

Coding Python in Linux

You can use any built-in text editor to write python files, e.g. nano or vi (but only use vi if you already know it!).
There are numerous IDEs (Integrated Development Environments) that you can use to make it easier to write Python. They generally provide syntax highlighting and some degree of auto-completion and pop-up docn.

  • idle (/usr/bin/idle) – it’s not liked by everyone but it’s already installed, and generally ok.

  • idlex – an extension for idle.

  • geany – (sudo apt-get -install geany) – A general IDE for multiple languages. You’ll need to add a debug execute build command: sudo python -m pub "%f" so you can run with the debugger.

Coding Python In Windows

Coding Python in OS X

  • Python is already installed in OS X, but at this time only python2. You may want to install python3. You can do this directly, or use Homebrew (brew install python2 / python3) if you want to insulate your python versions from the system installation, which could change as Apple updates OS X.

  • There’s a good choice of python editors for OS X. Some are free – choose your preferred.

Coding Python In iOS

  • Pythonista describes itself as The Zen of Python on iOS. It’s a full-featured code editor and a Universal app so you can run it on your iPhone, iPad, or iPod Touch.

Debuggers

Debuggers are built into each IDE.

  • pdb – Ready-installed in raspbian, run: /usr/bin/pdb

Tracing

Run your program under python with the -m trace option. i.e.:

python -m trace …

There are various options, e.g.:

python -m trace --trace file.py > trace.out

Converting Python 2 programs to Python3

Use the 2to3 program.

NEXT -> Part Three: Modules and Coding