Import, how to change sys.path on Windows, and module naming?
Jeremy Nicoll - news posts
jn.nntp.scrap001 at wingsandbeaks.org.uk
Sat Mar 1 12:29:21 EST 2008
If I understand correctly, when I import something under Windows, Python
searches the directory that the executing script was loaded from, then other
directories as specified in "sys.path".
I assume there are standard locations inside my installed Python - in my
case inside: C:\Program Files\~P-folder\Python25 - where I could put my
modules and they'd automatically be found? But even if that's the norm, I
don't want to put my own modules in such directories, partly because a
uninstall or reinstall or upgrade of Python might lose my stuff, and partly
because I don't believe in mixing distributed code with home-grown code.
However I'm quite happy to have a line or three of code to alter sys.path
to suit my set-up, if that's a normal way to handle this problem. Where
does one do that?
Also, I presume that there's a risk that the module name that I give to any
of my utilities will clash with a present or future standard module's name.
Does that mean that I should give my own modules names like "JNfoo" rather
than "foo", etc? Or something like "JNutils.foo"?
--
Jeremy C B Nicoll - my opinions are my own.
More information about the Python-list
mailing list