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 

Ayyyyeeee! /facepalm

Of course the caller can just pass locals() to the context manager. Why 
didn't I think of that?

I think I'm okay with that as a solution, but...
 
>>>> def mutate():
> ...     locals = sys._getframe(1).f_locals ...     locals["x"] = 4
> ...

I'll play around with that too. Just for kicks :-)



-- 
Steve

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to