Creating Python Modules

DH no at sp.am
Thu Mar 25 12:33:19 EST 2004


Adam T. Gautier wrote:

> Greetings,
> 
> I am trying to create a python module for a series of class files that 
> because of their size I have divided into multiple files.
> 
> class Foo --> foo.py
> class Boo --> boo.py

Create an __init__.py file in your module's root directory that calls:
from foo import Foo
from boo import Boo

Then to use your module, a user would do:

from mymodule import Foo, Boo
foo = Foo()
boo = Boo()

or...

import mymodule
foo = mymodule.Foo()
boo = mymodule.Boo()




More information about the Python-list mailing list