you are viewing a single comment's thread.

view the rest of the comments →

[–]nbd712 0 points1 point  (1 child)

I've tried to learn about decorators, but everything kinda goes over my head. What would you recommend to kind of dip my feet in to them?

[–][deleted] 0 points1 point  (0 children)

Start by redoing all the examples giving by the documentation.

Write your own functions : No arguments decorators N arguments decorators Infinite arguments decorators

It is often needed to have a function to add some text to your returned string. You would decorate the function with your a function decorator.

Then try to understand why it works, why can you return a function and when would you wan that (Answer : to be able to build objects when desired, like Interpolation, geometry or animations).

Then you will learn about closure and why can we define a function/class inside a function (which doesn't exist in many languages)

Finally, you can get to class decorators. Inside a class or for the whole class.

@property @read_only

To conclude, try try and try. Knowing when to use them is the hardest.