[Tutor] Odd AttributeError

Neil Hodge neh@attbi.com
Wed May 21 09:58:01 2003


All:

I have the following code:

def __init__(self, file, name='unknown filename', as_tuple=0):
    .
    .
    .
    print 'printing as_tuple:', as_tuple
    print 'defining self.as_tuple . . .'
    self.as_tuple = as_tuple
    print 'printing self.as_tuple: ', self.as_tuple

and the following output:

printing as_tuple: 0
defining self.as_tuple . . .
printing self.as_tuple:
Traceback (most recent call last):
  File "./id3-tagger.py", line 93, in ?
    main()
  File "./id3-tagger.py", line 68, in main
    id3info = ID3(file)
  File "./ID3.py", line 211, in __init__
    print 'printing self.as_tuple: ', self.as_tuple
AttributeError: ID3 instance has no attribute 'as_tuple'

So, why does self.as_tuple not exist right after I defined it?  Thanks.

Neil