[Tutor] Question about python decorators

Roel Schroeven roel at roelschroeven.net
Mon Jul 11 07:11:45 EDT 2022


Op 11/07/2022 om 12:58 schreef nathan tech:
> As I understand it, decorators are usuallyed created as:
> @object.event
> Def function_to_be_executed():
> Do_stuff
>
> My question is, is there a way to create this after the function is created?
> So:
> Def function():
> Print("this is interesting stuff")
>
> @myobject.event=function
>
Oops, sorry, there is an error in my other mail!

It should be:

     function = myobject.event(function)

instead of just

     function = myobject.event


-- 
"Peace cannot be kept by force. It can only be achieved through understanding."
         -- Albert Einstein



More information about the Tutor mailing list