Importing modules...

Aaron Ginn aaron.ginn at motorola.com
Fri Jul 14 15:59:00 EDT 2000


My apologies if this has been asked before.  If so, please direct me to
a FAQ.  I checked Deja, but I couldn't find my answer very easily...

How do I import a module that I have written?  Say I have a class that
I have created called Foo in a file stored at ~/bin/foo.py.  What kind
of command do I need to use to be able to import that class into a new
file.  I've tried the following:

import '~/bin/foo.py'

but this doesn't seem to be the way to do it.  Do I need to set a path
variable with ~/bin in it, and if so, how do I refer to the module?
Is it the name of the file, i.e. foo?  Or is it the name of the class,
i.e. Foo?  Do the class and the file need to have the same name?  I
don't really know how to accomplish this.

Thanks,
Aaron

-- 
Aaron J. Ginn                     Motorola SPS
Phone: (480) 814-4463             SemiCustom Solutions
Fax:   (480) 814-4058             1300 N. Alma School Rd.
mailto:aaron.ginn at motorola.com    Chandler, AZ 85226



More information about the Python-list mailing list