Explore >> Select a destination


You are here

florimond.dev
| | davidbieber.com
10.3 parsecs away

Travel
| | The implementation of hoist in my earlier snippet returned the values of local variables of all functions called by the hoisted function. This new version only returns the locals of the hoisted function. As before, you can use it like this: def f(x): y = x + 1 z = y * 2 return z + 1 f(4) == 11 hoist(f)(4) == {'x': 4, 'y': 5, 'z': 10, 'return': 11} Here's another usage example:
| | blog.nuculabs.de
10.5 parsecs away

Travel
| | Hello, In this short article I would like to talk about context managers. I personally consider that at the core they are just a form of decorators. If you don't know what a decorator is check the Decorator Pattern Wikipedia article. Decorators can be used to implement cross-cutting concerns. We have componentA and we need logging and security, we could write the logic for logging and security handling in componentA but some people consider component a should be componentA not componentAthatAlsoKnowsAboutSecurityAndOtherStuff. Since it's not the component's responsibility to authorize requests or log calls to a external logging service, we can wrap the componentA into a decorator that does just that.
| | www.pmatiello.me
10.8 parsecs away

Travel
| | Implementing interface contracts in Python with class decorators
| | tenthousandmeters.com
39.2 parsecs away

Travel
| Have you ever wondered what python does when you run one of your programs? $ python script.py This article opens a series which seeks to answer...