Does python have a "causes_exception()" function?
<p>I have the following code:</p>

<pre><code>def causes_exception(lamb):
    try:
       lamb()
       return False
    except:
       return True
</code></pre>

<p>I was wondering if it came already in any built-in library?</p>

<p>Ya'ir</p>

<p>Edit: Thx for all the commentary.  It's actually impossible to detect whether code causes an exception without running it -- otherwise you could solve the halting problem (raise an exception if the program halts).  I just wanted a syntactically clean way to filter a set of identifiers for those where the code didn't except.</p>
