Location of Python modules

Fredrik Lundh fredrik at pythonware.com
Mon Feb 13 14:00:32 EST 2006


"Byte" <eoinrogers at gmail.com> wrote:

> Found it in /usr/local/lib/python2.4/site-packages, thanks. Now, how do
> i convert a .py program into a module?

a .py program is a module (the module's content is what's left when the
program is finished).

to make a useful module, just make sure that it defines all the stuff you
want to make available (functions, classes, constants, etc), and that it
doesn't have any unexpected side-effects.

to create a script that can be used both as a script and as a module, you
can check the __name__ variable.  see:

    http://diveintopython.org/getting_to_know_python/testing_modules.html

for more on this.

</F>






More information about the Python-list mailing list