[Tutor] class again
Remco Gerlich
scarblac@pino.selwerd.nl
Sun, 2 Dec 2001 21:19:34 +0100
On 0, fleet@teachout.org wrote:
> I have followed the example in Core Python Programming (pg 403) re;
> AddrBookEntry class. If I type it in at the interactive Python prompt
> everything works fine. When I try to put the class in a file
> (addrbook.py) and 'import addrbook' I get no complaints; but I can't
> instantiate the class. (Ie, john = AddrBookEntry('John Doe',
> '405-555-1212'). I get NameError: AddrBookEntry.
>
> Where did I fall off the track?
After you do 'import addrbook', you can access the module addrbook.
AddBookEntry is a class inside that module, so you have to instantiate it like
john = addrbook.AddrBookEntry(.....)
--
Remco Gerlich