[Tutor] Question about python decorators

Nathan Smith nathan-tech at hotmail.com
Tue Jul 12 01:44:01 EDT 2022


Aha! I am with you.

Thanks a lot! :)

On 12/07/2022 00:09, Cameron Simpson wrote:
> On 11Jul2022 22:29, nathan tech <nathan-tech at hotmail.com> wrote:
>> For some reason though I have a library that is not behaving this way,
>> to example:
>>
>> @object.attr.method
>> def function():
>>   do stuff
>>
>> works, but
>>
>> object.attr.method=func
>>
>> does not
> That should be:
>
>      func = object.attr.method(func)
>
> Remember, a decorator takes a function and returns a function (often a
> new function which calls the old function).
>
> Cheers,
> Cameron Simpson <cs at cskk.id.au>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Ftutor&data=05%7C01%7C%7C1ed565f9951245e8f3fc08da6393ba6a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637931783391597551%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=1Y9J0uqLL66FgSohUUNtkOtIbE6wNOunUVKlHl9pZSg%3D&reserved=0
-- 

Best Wishes,

Nathan Smith, BSC


My Website: https://nathantech.net




More information about the Tutor mailing list