Python 'with' statement - how to tell what module/object/class supports it?
<p>Raymond Hettinger surprised quite a few people when he showed slides 36 and 37. <a href="https://speakerdeck.com/pyconslides/transforming-code-into-beautiful-idiomatic-python-by-raymond-hettinger" rel="nofollow">https://speakerdeck.com/pyconslides/transforming-code-into-beautiful-idiomatic-python-by-raymond-hettinger</a> -- Many people knew that the with statement could be used for opening files, but not these new things. Looking at python 3.3 docs on threading, only at the very bottom, section 16.2.8, is it even mentioned.  From the lecture it was implied that using the 'with' operator was best practice.</p>

<ul>
<li>How is one supposed to figure out if 'with' is supported, what it can be tied to, etc?</li>
<li>Also, how should 'with' be referred to? (threading with statement, python threading lock with statement,...), what is the vernacular to search and see if 'with' is supported (we can ask if something is iterable, do we ask if it's 'withable')?</li>
</ul>

<p>ref:</p>

<ul>
<li><a href="http://docs.python.org/2/reference/compound_stmts.html#with" rel="nofollow">http://docs.python.org/2/reference/compound_stmts.html#with</a> 7.5</li>
<li><a href="http://docs.python.org/2/reference/datamodel.html#context-managers" rel="nofollow">http://docs.python.org/2/reference/datamodel.html#context-managers</a> 3.4.10</li>
<li><a href="http://docs.python.org/3.1/library/threading.html" rel="nofollow">http://docs.python.org/3.1/library/threading.html</a> 16.2.8</li>
</ul>
