When to put my modules
loic at yermat.net1.nerim.net
Tue Dec 30 11:16:42 CET 2003
"Bob van der Poel" <bvdpoel at kootenay.com> a écrit dans le message de
news:3ff0e744_1 at dns.sd54.bc.ca
> I'm working on a moderately sized application and I'm planning on
> having a fair number of modules. The only question in my mind is:
> where do I put the modules ... and how do I let python know about
see http://www.python.org/doc/current/tut/node8.html especially the 6.1.1
> I could put them with the rest of the python lib, but I'm not really
> presumtious to do that.
Not that good...
> I can keep them all in the current directory, but that forces the user
> to chd to a certain location all the time.
> Best, I think, is to put them in a program specific location. My
> program needs some other data files, etc. so I'm thinking that I can
> just put the python stuff in /usr/local/lib/MYPROGRAM/modules.
Not that good too. You may want to re-use your module later in another
> Okay, but what about when I'm just working on them? In this case I'd
> like them to be in my current working dir.
> Is there a magic line I need to add to the top of the main module to
> set the path up?
> Apologies if this is covered in a document...but I can't see to find
> anything. Maybe this is a faq?
What I'm doing is something like this :
All my module are in a directory such as /home/loic/MyPython/.
I set the PYTHONPATH to that directory.
I've got for example a module rtf in /home/loic/MyPython/rtf/, another one
Heredis in /home/loic/MyPython/Heredis and my program is in
/home/loic/MyPython/Heredis2Gedcom for example.
In that way, I don't mix my module with standard one. Every program can
access all non program specific module.
For other tips, look at sys.path too.
Hope it help !
More information about the Python-list