static, class and instance methods (Reposting On Python-List Prohibited)

ast nomail at com.invalid
Thu Oct 6 05:03:15 EDT 2016


"Lawrence D’Oliveiro" <lawrencedo99 at gmail.com> a écrit dans le message de 
news:f5314bdd-a98f-4a16-b546-bd8efe4dd568 at googlegroups.com...
> On Thursday, October 6, 2016 at 7:54:08 PM UTC+13, ast wrote:
>> But there is no decorator, why ? Is python doing the conversion
>> of funct2 to a descriptor itself, behind the scene ?
>
> Every function is already a descriptor. So you get the instance-method behaviour automatically.
>
>> * static methods are decorated too
>
> This is to turn off the instance-method behaviour.


I do not understand your answer.
Consider this function:

def add(a, b):
    return a+b

You say that a function is always stored as
a descriptor object, so when I execute

sum = f(4, 6)

from which class it is supposed to come from ?









More information about the Python-list mailing list