[Tutor] Questions on 'records and structs' from tutorial...

alan.gauld@bt.com alan.gauld@bt.com
Mon Jan 20 06:42:02 2003


> class Employee:
> 	pass
> 
> john = Employee()
> 
> i got the following error:
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> NameError: name 'Employee' is not defined

It works for me:

>>> class Employee:
...    pass
...
>>> john = Employee()
>>> print john
<__main__.Employee instance at 0x007A7360>
>>>

The only thing I can think of, assuming you are iusing the 
interpreter directly is that you didn't type the extra ENTER
needed to get back to the >>> prompt after defining Employee.
But that gives a different error message(Syntax error).

Alan g.
Author of the Learn to Program website
http://www.freenetpages.co.uk/hp/alan.gauld/