Observer-Pattern by (simple) decorator

Wildemar Wildenburger wildemar at freakmail.de
Sat Jun 2 12:42:04 EDT 2007


Steven Bethard wrote:
> Wildemar Wildenburger wrote:
>   
>>>>> class Observable(object):
>>>>>           
>> ...     def __init__(self, func, instance=None, observers=None):
>> ...         self.func = func
>> ...         self.instance = instance
>> ...         self.observers = observers or []
>>     
>
> Unless you also changed code in __get__, this means you'll get a new 
> list every time you access the "meth" attribute since the __get__ method 
> is called anew for every attribute access::
>
>
>   
Man! Nothing is easy ...

;)

/W




More information about the Python-list mailing list