On Tue, Feb 1, 2011 at 1:38 PM, Gerald Britton <gerald.brit...@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 > definition. > > 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[1], I don't see any generic way to tell if you are within a context manager. 1: http://www.python.org/dev/peps/pep-0343/ -- Jerry
-- http://mail.python.org/mailman/listinfo/python-list