On Fri, Jan 19, 2018 at 5:00 PM, wrote:
> Hello,
>
> Thank you for your mail. I will answer as fast as possible.
If you're going to subscribe to a mailing list, PLEASE disable your
autoresponder.
Otherwise, messages like this will get marked as Spam, and your legit
mail will end up getting tarr
On Fri, 19 Jan 2018 16:49:49 +1100, Chris Angelico wrote:
[...]
> 1) Context manager was called from global scope, and needs access to
> globals() or locals() as returned in the caller
A! /facepalm
Of course the caller can just pass locals() to the context manager. Why
didn't I think o
On Fri, Jan 19, 2018 at 3:48 PM, Steven D'Aprano
wrote:
> I want to define a context manager in one module:
>
> # a.py
> def CM:
> def __enter__(self):
> return self
> def __exit__(self, *args):
> pass
>
>
> Then call it from another module:
>
> # b.py
> import a
> with a.C
I'm looking for a solution, or at least hints, to this problem.
I want to define a context manager in one module:
# a.py
def CM:
def __enter__(self):
return self
def __exit__(self, *args):
pass
Then call it from another module:
# b.py
import a
with a.CM() as spam: