Some time ago I asked on Twitter: I was curious what you use #Python decorators for? And I got quite an amazing / insightful response: The obvious next step for me was to look at some examples / use cases. So below are 5 useful applications of decorators. Study them, then apply similar things to… Continue reading 5 Helpful Python Decorator Use Cases
Articles on decorators
PyBites Twitter Digest – Issue 38, 2018
By PyBites Team on 9 December 2018
Every weekend we share a curated list of 15 cool things (mostly Python) that we found / tweeted throughout the week.
PyBites Twitter Digest – Issue 29, 2018
By PyBites Team on 16 September 2018
Every weekend we share a curated list of 15 cool things (mostly Python) that we found / tweeted throughout the week.
PyBites Twitter Digest – Issue 27, 2018
By PyBites Team on 19 August 2018
Every weekend we share a curated list of 15 cool things (mostly Python) that we found / tweeted throughout the week.
Learning Python Decorators by Example
By Bob Belderbos on 20 October 2017
Decorators are a sometimes overlooked feature and they might be hard to grasp for beginning Pythonistas. I agree with Aaron Maxwell that mastering them “can massively magnify the positive impact of the code you write”, so make sure you add them to your toolkit if not done so already. In this article I explain what they do, why you want to use them and give some practical examples.
OOP Beyond the Basics: Using Properties for Encapsulation, Computation and Refactoring
By Bob Belderbos on 31 May 2017
In this article I share my learning of the property decorator coding a simple Account class. I think it’s an unmissable tool in your (Python) OOP toolkit.
Code Challenge 14 – Write DRY Code With Decorators – Review
By PyBites Team on 14 April 2017
It’s end of the week again so we review the code challenge of this week. It’s never late to sign up, just fork our challenges repo and start coding.
Beginning Flask
By Julian Sequeira on 13 April 2017
In this post I cover the basics of Flask in language that anyone can understand.
How to Write a Decorator with an Optional Argument?
By Bob Belderbos on 11 April 2017
When playing with decorators (this week’s challenge) I got stuck: how do you write a decorator that takes an optional argument? Python cookbook 3rd ed edition to the rescue. In this post how I failed my way to the right solution.
Code Challenge 14 – Write DRY Code With Decorators
By PyBites Team on 10 April 2017
Hi Pythonistas, a new week, a new ‘bite’ of Python coding! This week we let you practice with decorators, a nice way to abstract away common functionality. It allows you to alter the behavior of a callable without modifying the callable itself. We agree with Dan Bader that ‘understanding decorators is a milestone for any serious Python programmer.’ Enjoy!