class creation

Alex Martelli aleax at aleax.it
Fri Dec 26 10:29:34 CET 2003


km wrote:

> Hi all,
> 
> If i create a class "REX" and want to import it  and test its
> implementation in a python script  what should be the file name of the
> class file be ?

Whatever you wish, as long as the extension is .py and you place
the file in some directory along Python's sys.path.

For example, if your "class REX:" (etc) is located in blaugh.py
in the current directory,

import blaugh
r = blaugh.REX()

is how you instantiate the class to get an instance r you can
call methods on.


Alex





More information about the Python-list mailing list