Module organization

Lasse Vågsæther Karlsen lasse at vkarlsen.no
Wed Sep 28 06:54:38 EDT 2005


I am slowly learning Python and I'm already starting to write some minor
modules for myself. Undoubtedly there are better modules available
either built-in or 3rd party that do the same as mine and much more but
I need to learn it one way or another anyway.

What I'm wondering about is module organization.

I created my own directory for storing my modules and added the full
path to this to PYTHONPATH (Windows XP platform).

This means that "import modulename" works for my modules now.

However, the name of my module is "db" or "database", a module name that
will likely conflict with other modules I might encounter later.

As such, I was thinking of doing the same that the "distutils" set of
modules have done, by creating a subdirectory and storing them there, so
I created a "lvk" directory in that directory of mine and moved the
module in there, but now "import lvk.modulename" doesn't find the module.

Is there a trick to this? Do I have to store my own modules beneath
C:\Python24\Lib? or can I use the organization I've tried just with some
minor fixes to make python locate my modules?

-- 
Lasse Vågsæther Karlsen
http://usinglvkblog.blogspot.com/
mailto:lasse at vkarlsen.no
PGP KeyID: 0x2A42A1C2



More information about the Python-list mailing list