argument checking before getattr

Jason Orendorff jason at
Sun Jan 13 11:28:39 EST 2002

> I guess __getattr__ would apply the function object
> internally. Would it?

No.  If you write code like
  print object.attribute
then Python does, basically,
  print getattr(object, 'attribute')

If you write:
then Python does, basically:
  m = getattr(object, 'method')

When you override __getattr__, it only changes
the getattr behavior.  __getattr__ does not call
the method.  The method still gets called
as usual, with the arguments you provide.

## Jason Orendorff

More information about the Python-list mailing list