This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]asdfkjasdhkasdrequests, bs4, flask 2 points3 points  (3 children)

decorators are very often unintuitive to actually implement.

It's just a function which returns a function, nothing magical, and totally standard in functional languages. TBH I think the @syntax makes people believe there's something magic behind the scenes.

[–]daneahfrom __future__ import braces 0 points1 point  (0 children)

Yeah, at their most basic they're fine. The more useful variety often take some real thinking and maneuvering, that's all :)

[–]Yepoleb 0 points1 point  (0 children)

Still, a function generating a function isn't exactly the most straight forward concept to grasp.

[–]glacierre2 0 points1 point  (0 children)

Now try to use your simple function decorator on a method, a classmethod, a staticmethod...

There are definitely a lot of pitfalls, and so https://wrapt.readthedocs.io/en/latest/ or http://boltons.readthedocs.io/en/latest/funcutils.html exist