Link: The Python decorators they won't tell you about

January 7, 2018

H. Chase Stevens The decorators they won't tell you about (via Hacker News, repeatedly; it's been posted several times) is another view of Python decorators. I'll give you a quote that shows the flavour:

Decorators are often described as "functions which take functions and return functions", a description which is notable in that, technically speaking, not a single word of it is true.

(H. Chase Stevens is right about this, by the way.)

If you're interested in understanding more about what decorators are and some clever (or crazy) things they can be used for beyond the obvious, this is well worth reading. I certainly enjoyed it, even if some of the tricks it shows are things that I'd probably never use in real code.

(Breaking out of conventional views is always useful, in my opinion.)

By the way, the article is a Python Jupyter notebook and as such, you need to turn on JavaScript in order to view it on Github (and apparently people may have problems on mobile devices). An alternate view that doesn't require this is here (via).

Written on 07 January 2018.
« What's happening when you change True and False in Python 2
The challenges of having true constants in Python »

Page tools: View Source, Add Comment.
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Sun Jan 7 16:36:35 2018
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.