bruno at modulix wrote:
> Ziga Seilnacht wrote:
>> bruno at modulix wrote:
>>
>>> Hi
>>>
>>> I'm currently playing with some (possibly weird...) code, and I'd have a
>>> use for per-instance descriptors, ie (dummy code):
>>
>> <snip>
>>
>>> Now the question: is there any obvious (or non-obvious) drawback with
>>> this approach ?
>>
...
> 
>> ...     def __getattribute__(self, name):
>> ...         v = object.__getattribute__(self, name)
>> ...         if not isinstance(v, types.FunctionType) \
>                 and hasattr(v, '__get__'):
>> ...             return v.__get__(self, self.__class__)
>> ...         return v
> 
> 
I may be missing the subtlety of what you're up to, but why is overriding 
__getattribute__ more desirable than simply defining the descriptor in a  
subclass?
i.e.,
class MyClass3(MyClass1):
   def __init__(self, bar=None):
     if bar is not None:
       self.bar = bar
   baaz = DummyDescriptor()


Michael

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to