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

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"

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s