[Python-ideas] except expression

Alexander Belopolsky alexander.belopolsky at gmail.com
Wed Feb 19 02:34:25 CET 2014


On Tue, Feb 18, 2014 at 7:10 PM, Steven D'Aprano <steve at pearwood.info>wrote:

> > I disagree.  It is best to leave explicit selection of exceptions to
> catch
> > outside of the expressions.  This is job for things like decimal or numpy
> > fp contexts.
>
> I don't understand what relevance fp contexts have here.


>>> numpy.seterr(divide='ignore')
{'over': 'warn', 'divide': 'raise', 'invalid': 'warn', 'under': 'ignore'}
>>> 1/numpy.array(0.0)
inf
>>> numpy.seterr(divide='raise')
{'over': 'warn', 'divide': 'ignore', 'invalid': 'warn', 'under': 'ignore'}
>>> 1/numpy.array(0.0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
FloatingPointError: divide by zero encountered in divide
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140218/c7c6fae9/attachment.html>


More information about the Python-ideas mailing list