[Tutor] Class error
Alan Gauld
alan.gauld at btinternet.com
Mon Jun 18 01:00:36 CEST 2007
"Henry Dominik" <fiveholiday55 at hotmail.com> wrote
> Besides, why did I have to do this: class
> EmplAddrBookEntry(AddrBookEntry.AddrBookEntry):
>
> The AddrBookEntry and EmplAddrBookEntry classes
> are in the same folder,
Python doesn't care abpout the foldrs it only cares about
the modules. They are in different modules therefore you
need to import the other module. But importing the module
just makes the module name available inside your module.
To make the contents of the module available you must
reference the module. Modules are first class objects in
Python they are not simply files (although they are
implemented as simple files!) You might think of the
module as being like a class that you can't instantiate
if you like.
Alternarively you can use the other form of import:
from Module import Name
In your cae that would be
from AddrBookEntry import AddrBookEntry
Now when you use AddrBookentry it refers to the named object
inside the AddrBookEntry module.
HTH,
Alan G.
More information about the Tutor
mailing list