Lee Harr a écrit :
>>>I think the term "class decorator" is going to eventually
>>>mean something other than what you are doing here. I'd
>>>avoid the term for now.
>>>
>>>
>>>When you decorate a class method,
>>>the function you use
>>>needs to be defined before the method definition.
>>
>>FWIW, t
>> I think the term "class decorator" is going to eventually
>> mean something other than what you are doing here. I'd
>> avoid the term for now.
>>
>>
>> When you decorate a class method,
>> the function you use
>> needs to be defined before the method definition.
>
> FWIW, the term "class metho
Chris Fonnesbeck schrieb:
> I have a class that does MCMC sampling (Python 2.5) that uses decorators
> -- one in particular called _add_to_post that appends the output of the
> decorated method to a class attribute. However, when I
> subclass this base class, the decorator no longer works:
>
>
Chris Fonnesbeck a écrit :
> I have a class that does MCMC sampling (Python 2.5) that uses decorators
> -- one in particular called _add_to_post that appends the output of the
> decorated method to a class attribute.
> However, when I
> subclass this base class, the decorator no longer works:
>
Lee Harr a écrit :
>> Traceback (most recent call last):
>> File "/Users/chris/Projects/CMR/closed.py", line 132, in
>> class M0(MetropolisHastings):
>> File "/Users/chris/Projects/CMR/closed.py", line 173, in M0
>> @_add_to_post
>> NameError: name '_add_to_post' is not defined
>>
>> y
> Traceback (most recent call last):
> File "/Users/chris/Projects/CMR/closed.py", line 132, in
> class M0(MetropolisHastings):
> File "/Users/chris/Projects/CMR/closed.py", line 173, in M0
> @_add_to_post
> NameError: name '_add_to_post' is not defined
>
> yet, when I look at the dict
I have a class that does MCMC sampling (Python 2.5) that uses decorators
-- one in particular called _add_to_post that appends the output of the
decorated method to a class attribute. However, when I
subclass this base class, the decorator no longer works:
Traceback (most recent call last):
F