Explore >> Select a destination


You are here

juandebravo.com
| | www.pmatiello.me
3.8 parsecs away

Travel
| | Implementing interface contracts in Python with class decorators
| | juandebravo.com
0.6 parsecs away

Travel
| | Juan de Bravo - Personal thoughts about technology (@juandebravo)
| | www.integralist.co.uk
3.0 parsecs away

Travel
| | Introduction In this post I wanted to discuss a relatively simple, but important topic: Context Managers. I want to cover the what, the why and the how. But before we get into it... time for some self-promotion ?? Want to be up and running quickly with Python? Get started here with my book "Python for Programmers"! Summary Content Managers abstract away 'clean-up' logic. Define a class with __enter__/__exit__ methods. The __enter__ method is similar to a try block.
| | aaronluna.dev
22.6 parsecs away

Travel
| Decorators can be a daunting topic when first encountered. While the Zen of Python states "There should be one- and preferably only one -obvious way to do it", there are many, equally valid ways to implement the same decorator. These different methods can be categorized as either function-based, class-based, or a hybrid of both. In this post I will explain the design and behavior of Python decorators and provide examples of decorators that I frequently use in my own code.