Returning an element from a C struct

Bertrand Geston bergeston at yahoo.fr
Thu Mar 21 10:44:18 EST 2002


"Armin Rigo" <arigo at ulb.ac.be> wrote in message
news:3c990582$0$29676$ba620e4c at news.skynet.be...
> > How about
> >
> >     def __getattr__(self,name):
> >         try:
> >             return self.__dict__[name]
> >         except KeyError:
> >             return getattr(self.ptr, name)
>
> It even looks like the first 'return' is not needed. If the attribute is
> found in the instance then __getattr__() is not called at all.
>
> Armin
>
... but AFAIK in Python 2.2, if __getattribute__(self, key) is implemented,
it is called anyway.





More information about the Python-list mailing list