Python recursively __getattribute__
Terry Reedy
tjreedy at udel.edu
Mon Nov 22 12:57:18 EST 2010
On 11/22/2010 10:46 AM, Roman Dolgiy wrote:
> Hello,
>
> I need to implement such behavior:
>
> obj.attr1.attr2.attr3 --> obj.attr1__attr2__attr3
obj.attr1.attr2.attr3 is parsed as ((obj.attr1).attr2).attr3,
so this cannot work in general but only if attr1 and attr2 are known to
not be 'final' names.
> It looks like I have to override obj's class __getattribute__ and also
> use python descriptors somehow.
>
> Any help will be much appreciated.
> http://stackoverflow.com/questions/4247036/python-recursively-getattribute
The code posted there by THC4k depened on such knowledge, which you gave
there but not here.
--
Terry Jan Reedy
More information about the Python-list
mailing list