delegation pattern via descriptor

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Tue Jul 6 15:46:41 EDT 2010


Gregory Ewing a écrit :
> Bruno Desthuilliers wrote:
>> kedra marbun a écrit :
>>
>>> if we limit our discussion to py:
>>> why __{get|set|delete}__ don't receive the 'name' & 'class' from
>>> __{getattribute|{set|del}attr}__
>>> 'name' is the name that is searched
>>
>>
>> While it would have been technically possible, I fail to imagine any use
>> case for this.
> 
> I think he wants to have generic descriptors that are
> shared between multiple attributes, but have them do
> different things based on the attribute name.

I already understood this, but thanks !-)

What I dont understand is what problem it could solve that couldn't be
solved more simply using the either _getattr__ hook or hand-coded
delegation, since such a descriptor would be so tightly coupled to the
host class that it just doesn't make sense writing a descriptor for this.



More information about the Python-list mailing list