On Tue, Feb 1, 2011 at 11:34 AM, Gerald Britton <gerald.brit...@gmail.com>wrote:

> x = open('somefile')
> # return false since not in a context
> with open('somefile') as x
> # return true since in a context.
>

Perhaps something like this:

x = open('somefile')
if hasattr(x, '__enter__'):
    return false
with open('somefile') as x:
    do_something()

-- 
Jerry
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to