Accessing attributes

Marc Christiansen usenet at solar-empire.de
Tue Jun 12 06:09:30 EDT 2007


Jeff Rollin <jeffrey.rollin at gmail.com> wrote:
> I'm working with the Python Tutorial "Byte of Python" at swaroopch.info.
> 
> I have created the attached file, but when I execute:
> 
> % objvar.py
> 
> I get the error message:
> 
> (Initializing Calamity Jane)
> Traceback (most recent call last):
>  File "/home/jef/bin/objvar.py", line 49, in <module>
>    Person.how_many()
> AttributeError: class Person has no attribute 'how_many'
> 
> Where am I going wrong?

The indentation of __del__, say_hi and how_many is wrong. You define
them inside __init__. Move them to the same indentation level as
__init__ and all should work.



More information about the Python-list mailing list