<div class="gmail_quote">On Tue, Feb 1, 2011 at 11:34 AM, Gerald Britton <span dir="ltr"><<a href="mailto:gerald.britton@gmail.com">gerald.britton@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
x = open('somefile')<br>
# return false since not in a context<br>
with open('somefile') as x<br>
# return true since in a context.<br></blockquote></div><br>Perhaps something like this:<br><br>x = open('somefile')<br>if hasattr(x, '__enter__'):<br> return false<br>with open('somefile') as x:<br>
do_something()<br><br>-- <br>Jerry<br>