How can I tell if I am inside a context manager?
malaclypse2 at gmail.com
Tue Feb 1 20:38:37 CET 2011
On Tue, Feb 1, 2011 at 1:38 PM, Gerald Britton <gerald.britton at gmail.com>wrote:
> As you can see, the object has a '__enter__' method regardless of how
> it was created. Whatever the test, it needs to return False in the
> first case and True in the second case, without modifying the class
I'm sorry, I completely misunderstood your question. I thought you were
asking how you could tell if something provided a context manager. Based on
the PEP, I don't see any generic way to tell if you are within a context
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list