A collection of Python tips and tricks that I'm picking up. As always, a work in progress.
Tools
- python mode.el -- hacked
The is a version of python-mode.el which is distributed with Python, but it seems a little bit older that what is in the SourceForge project for python-mode.el. The version that I've linked above is version 4.49 from CVS and has the changes needed for IPython merged in.
- ipython
IPython is an enhancement for the regular Python interpreter loop. It adds session recording, completion, aliases and maros, access to the shell and much more. If you do any work with the interpreter, you should install this. There is also support for running IPython as the python interpreter that is used when you run a Python interpreter in an Emacs buffer. The latest version of that support is here. You may also be interested in PyCrust, which does some of the things that IPython does. It runs as a GUI client and uses wxPython/wxWindows. It is particularly handy when you want to inspect lots of variables. I found it to be somewhat sluggish.
- PyChecker
Think of PyChecker as lint for Python, and you'll have the concept.
- epydoc or pythondoc
epydoc is a program for generating JavaDoc like documentation by embedding commands in Python docstrings. Pythondoc is a Python implementation of JavaDoc, so it uses very similar documentation comments. The advantage of this is that it does not pollute the docstrings with commands, allowing tools that work on docstrings to continue to work.
Tips
pydoc The pydoc command is included in the standard Python distribution, and provides a UNIX man style interface to the Python documentation. There is also a builtin web server mode which allows you to display the documentation in a browser
- Python 2.3 docs in Compiled Windows Help format
This is my favorite way to refer to the Python documentation. The big advantage of CHM format is that you can search the contents of the entire file. This can be a big help in getting around the documentation for reference purposes. On Windows, these files use the Windows Help viewer. On Mac OS X and Linux, you can use the open source program xchm to view these files. Chandler White has done the work to make xchm a standard (Carbon) Mac application.
- kcachegrind's
hotshot2cachegrind script If you need to use Python's hotshot profiler, then you might be interested in using kcachegrind's hotshot2cachegrind script, which converts hotshot profile files into cachegrind format. This allows you to use kcachegrind to visualize the profile results. The only potential drawback is that you need to have bunch of KDE libraries installed.
Mac OS X
- MacPython
MacPython refers to the port of Python to Mac OS X. Of particular interest is the MacPython 2.3 for Panther addons, which adds "The rest of the standard Python support" to the Python 2.3 that Apple shipped in Panther.
- http://pythonmac.org/
There is a whole Python community dedicated to Python on Mac OS X. These folks are doing a whole bunch of cool stuff including the PyObjC bridge, and AppScripting which lets you script Mac OS X applications using Python instead of AppleScript.
Resources
Wishlist
- A good refactoring editor/browser for Python
- Something like the CPAN shell for Python