Setup Python
If you are using Pythin < 3.3
, install virtualenv and virtualenvwrapper.
# virtualenvwrapper lists virtualenv as a dependency, so it's automatically installed
$ sudo pip install virtualenvwrapper
Virtualenv lets you create an isolated environment for each project. Especially useful when you use different versions of packages in different projects. Virtualenv wrapper provides a few nice scripts to make things a little easier.
IPython
IPython is an alternative to the standard Python REPL
that allows for auto complete, quick access to docs, and a slew of other features that really should have been in the standard REPL.
Simply pip install ipython
and type ipython (you can even create an alias in your shell alias py=ipython
)
Testing
If you are using Pythin < 3.3
install mock
for testing. Also install nose
.
$ pip install mock nose
Read more: https://docs.python.org/3/library/unittest.mock.html, https://nose.readthedocs.org/en/latest/
Debugging
iPDB
is an excellent tool to figure out some weird bugs. Install it pip install ipdb
and add the line import ipdb; ipdb.set_trace()
in your code, and you get a nice interactive prompt in your running program.
? for help
? l for help for command l
l for "some more context"
s for "step into"
n for "step over"
c for "continue"
Use pprint
for pretty printer.