Daily Archives: May 28, 2007

Python bits to remember

I’ve been going to the West Midlands Python User Group for a bit now and thanks to John Pinner of Clockwork software systems excellent sessions I have learnt a few more things about Python.

Use dir to examine things.

Use help to read the help about things.

Use sys.path to see where Python is looking for files.

import sys
sys.path

If you need to add another path to the search list you can use a .pth file to specify a path. There are commonly some in /usr/lib/python*/site-packages/. Sometimes they just point to a directory within that dir, othertimes it’s a directory far away. It appears that they can contain python but all you need is a path.

If you need to add a search path to apache you can do it like this,
PythonPath "['/usr/local/src/'] + sys.path"

Follow

Get every new post delivered to your Inbox.

Join 58 other followers