argument checking before getattr
Benjamin Tai
bt98 at doc.ic.ac.uk
Sun Jan 13 13:17:12 EST 2002
Hi Jason,
> > 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:
> object.method(args)
> then Python does, basically:
> m = getattr(object, 'method')
> m(args)
>
> 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.
Thank you very much for the reply. This is a different level of
understanding. How do you find these information? Presently I am reading
both of Mart Lutz books. Have I missed out too many chapters?
Ben
More information about the Python-list
mailing list