Bypassing __getattribute__ for attribute access

Bruno Desthuilliers bruno.42.desthuilliers at wtf.websiteburo.oops.com
Fri Oct 26 02:50:54 EDT 2007


Chris Mellon a écrit :
> On Thu, 2007-10-25 at 23:13 +0200, Bruno Desthuilliers wrote:
> <snip excellent breakdown>

<blush />

>> Dynamically adding methods to classes is pretty 
>> straightforward, the tricky point is to dynamically add methods to 
>> instances, since the descriptor protocol is only triggered for class 
>> attributes. But you obviously found how to do it using func.__get__(obj, 
>> type(obj)) !-)
>>
> 
> This is the greasy, getting your hands dirty way. I vastly prefer (and
> reccomend) using the new module:

Indeed.



More information about the Python-list mailing list