I wanted to talk about my development environment for Python.
I do all my main development under MacOS X, but deploy to other UNIX
systems. I write all my code using Vim
. I don't use syntax coloring, nor do I use folding. Sometimes I'll
use a split buffer when I'm feeling daring.
I make heavy use of
PyChecker
to check my code before running it. I really love it because it catches all
of the stupid mistakes I make.
Like many python programmers, I spend a lot of time typing small code
snippets directly into the python interpreter just to test things. This
is amazingly useful. Beyond using tab-copletion with readline, I like
to have my python history saved between sessions, so I use this in my
.pythonrc file:
import rlcompleter
import atexit
import os
import readline
from pydoc import help
# Make TAB complete stuff
readline.parse_and_bind("tab: complete")
# Save our interpreter history between sessions
historyPath = os.path.expanduser("~/.pyhistory")
def save_history(historyPath=historyPath):
import readline
readline.write_history_file(historyPath)
if os.path.exists(historyPath):
readline.read_history_file(historyPath)
atexit.register(save_history)
# clean up
del os, atexit, readline, rlcompleter, save_history, historyPath
I didn't write those history saving bits myself. They were found on the
net. Score! I've recently tried using
IPython, an enhanced interactive
python shell. I haven't switched over to it yet, but I think it's @edit
command is really cool.
When it comes time to debug, I'm a big fan of just using print
statements. Beyond that, I like to use 'python -i' to inspect the state of
variables in the interpreter, and rarely I'll use 'pdb.run()' to run code
under the debugger.
That's basically it. Nothing fancy, but the job gets done.
Take care.
|