Your Development Environment — The Hitchhiker's Guide to Python (original) (raw)

../../_images/33175624924_7febc46cc4_k_d.jpg

Text Editors

Just about anything that can edit plain text will work for writing Python code; however, using a more powerful editor may make your life a bit easier.

Vim

Vim is a text editor which uses keyboard shortcuts for editing instead of menus or icons. There are a couple of plugins and settings for the Vim editor to aid Python development. If you only develop in Python, a good start is to set the default settings for indentation and line-wrapping to values compliant withPEP 8. In your home directory, open a file called .vimrc and add the following lines:

set textwidth=79 " lines longer than 79 columns will be broken set shiftwidth=4 " operation >> indents 4 columns; << unindents 4 columns set tabstop=4 " a hard TAB displays as 4 columns set expandtab " insert spaces when hitting TABs set softtabstop=4 " insert/delete 4 spaces when hitting a TAB/BACKSPACE set shiftround " round indent to multiple of 'shiftwidth' set autoindent " align the new line indent with the previous line

With these settings, newlines are inserted after 79 characters and indentation is set to 4 spaces per tab. If you also use Vim for other languages, there is a handy plugin called indent, which handles indentation settings for Python source files.

There is also a handy syntax plugin called syntax featuring some improvements over the syntax file included in Vim 6.1.

These plugins supply you with a basic environment for developing in Python. To get the most out of Vim, you should continually check your code for syntax errors and PEP8 compliance. Luckily pycodestyle and Pyflakes will do this for you. If your Vim is compiled with +python you can also utilize some very handy plugins to do these checks from within the editor.

For PEP8 checking and pyflakes, you can install vim-flake8. Now you can map the function Flake8 to any hotkey or action you want in Vim. The plugin will display errors at the bottom of the screen, and provide an easy way to jump to the corresponding line. It’s very handy to call this function whenever you save a file. In order to do this, add the following line to your.vimrc:

autocmd BufWritePost *.py call Flake8()

If you are already using syntastic, you can set it to run Pyflakes on write and show errors and warnings in the quickfix window. An example configuration to do that which also shows status and warning messages in the statusbar would be:

set statusline+=%#warningmsg# set statusline+=%{SyntasticStatuslineFlag()} set statusline+=%* let g:syntastic_auto_loc_list=1 let g:syntastic_loc_list_height=5

Python-mode

Python-mode is a complex solution for working with Python code in Vim. It has:

And more.

SuperTab

SuperTab is a small Vim plugin that makes code completion more convenient by using <Tab> key or any other customized keys.

Emacs

Emacs is another powerful text editor. It is fully programmable (Lisp), but it can be some work to wire up correctly. A good start if you’re already an Emacs user is Python Programming in Emacs at EmacsWiki.

  1. Emacs itself comes with a Python mode.

TextMate

TextMate brings Apple’s approach to operating systems into the world of text editors. By bridging Unix underpinnings and GUI, TextMate cherry-picks the best of both worlds to the benefit of expert scripters and novice users alike.

Sublime Text

Sublime Text is a sophisticated text editor for code, markup, and prose. You’ll love the slick user interface, extraordinary features, and amazing performance.

Sublime Text has excellent support for editing Python code and uses Python for its plugin API. It also has a diverse variety of plugins,some of which allow for in-editor PEP8 checking and code “linting”.

Atom

Atom is a hackable text editor for the 21st century, built on atom-shell, and based on everything we love about our favorite editors.

Atom is web native (HTML, CSS, JS), focusing on modular design and easy plugin development. It comes with native package control and a plethora of packages. Recommended for Python development isLinter combined withlinter-flake8.

Python (on Visual Studio Code)

Python for Visual Studio is an extension for the Visual Studio Code. This is a free, lightweight, open source code editor, with support for Mac, Windows, and Linux. Built using open source technologies such as Node.js and Python, with compelling features such as Intellisense (autocompletion), local and remote debugging, linting, and the like.

MIT licensed.

IDEs

PyCharm / IntelliJ IDEA

PyCharm is developed by JetBrains, also known for IntelliJ IDEA. Both share the same code base and most of PyCharm’s features can be brought to IntelliJ with the freePython Plug-In. There are two versions of PyCharm: Professional Edition (Free 30-day trial) and Community Edition (Apache 2.0 License) with fewer features.

Enthought Canopy

Enthought Canopy is a Python IDE which is focused towards Scientists and Engineers as it provides pre installed libraries for data analysis.

Eclipse

The most popular Eclipse plugin for Python development is Aptana’sPyDev.

Komodo IDE

Komodo IDE is developed by ActiveState and is a commercial IDE for Windows, Mac, and Linux.KomodoEdit is the open source alternative.

Spyder

Spyder is an IDE specifically geared toward working with scientific Python libraries (namelySciPy). It includes integration with pyflakes,pylint andrope.

Spyder is open source (free), offers code completion, syntax highlighting, a class and function browser, and object inspection.

WingIDE

WingIDE is a Python specific IDE. It runs on Linux, Windows, and Mac (as an X11 application, which frustrates some Mac users).

WingIDE offers code completion, syntax highlighting, source browser, graphical debugger and support for version control systems.

NINJA-IDE

NINJA-IDE (from the recursive acronym: “Ninja-IDE Is Not Just Another IDE”) is a cross-platform IDE, specially designed to build Python applications, and runs on Linux/X11, Mac OS X, and Windows desktop operating systems. Installers for these platforms can be downloaded from the website.

NINJA-IDE is open source software (GPLv3 licence) and is developed in Python and Qt. The source files can be downloaded fromGitHub.

Eric (The Eric Python IDE)

Eric is a full featured Python IDE offering source code autocompletion, syntax highlighting, support for version control systems, Python 3 support, integrated web browser, python shell, integrated debugger, and a flexible plug-in system. Written in Python, it is based on the Qt GUI toolkit, integrating the Scintilla editor control. Eric is an open source software project (GPLv3 licence) with more than ten years of active development.

Mu

Mu is a minimalist Python IDE which can run Python 3 code locally and can also deploy code to the BBC micro:bit and to Adafruit boards running CircuitPython.

Intended for beginners, mu includes a Python 3 interpreter, and is easy to install on Windows, OS/X and Linux. It runs well on the Raspberry Pi.

There’s an active support community on gitter.