Could somebody _PLEASE_ explain what's going on here?

Michael Hudson mwh21 at cam.ac.uk
Fri Nov 3 20:15:08 CET 2000


Steve Juranich <sjuranic at condor.ee.washington.edu> writes:

> Okay, I'm getting really frustrated here because I don't understand what's
> going on.  Up to this morning, I had a class called "Table" that responded
> very nicely to the "print" command.  Now, all of a sudden, it doesn't work. 
> 
> I have made a change in the code.  I overloaded the '__getattr__' to the
> following:
> 
>     # 
>     # 
>     # This deals with accessing options that may have not been defined
>     # in the options file.
>     def __getattr__(self, k):
>         try:
>             return self.__dict__[k]
>         except KeyError:
>             return None

s/return None/raise AttributeError, k/

HTH, HAND,
M.

[...]
> >>> print t 
> 
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> TypeError: call of non-function (type None)
                                  ^^^^^^^^^^^
                       didn't this give you a clue?

-- 
  Our lecture theatre has just crashed. It will currently only
  silently display an unexplained line-drawing of a large dog
  accompanied by spookily flickering lights.
     -- Dan Sheppard, ucam.chat (from Owen Dunn's summary of the year)



More information about the Python-list mailing list