What is '@' for

Tim Daneliuk tundraBOGUS at tundraware.com
Fri Nov 13 18:43:15 EST 2015


On 11/13/2015 05:14 PM, Chris Angelico wrote:
> On Sat, Nov 14, 2015 at 10:04 AM, fl <rxjwg98 at gmail.com> wrote:
>> I read the following code snippet. A question is here about '@'.
>> I don't find the answer online yet.
>>
>> What function is it here?
>>
>>
>> @pymc.deterministic
>> def theta(a=alpha, b=beta):
>>     """theta = logit^{-1}(a+b)"""
>>     return pymc.invlogit(a+b*x)
> 
> That's called a "function decorator". And now that you know the name,
> you'll be able to find what it is online; as well as the Python docs,
> there are a number of blog posts and other articles about it.
> 
> ChrisA
> 


One small point of order ... if you want to be precise, "@pymc.deterministic" is a *function decoration*.  The "decorator" is the function pymc.deterministic().

I know this is a fussy point, but this distinction is helpful when first learning the concept.



More information about the Python-list mailing list