[Numpy-discussion] except expression discussion on python-ideas
Alexander Belopolsky
ndarray at mac.com
Tue Feb 18 22:18:04 EST 2014
I would like to invite numpy community to weigh in on the idea that is
getting momentum at
https://mail.python.org/pipermail/python-ideas/2014-February/025437.html
The main motivation is to provide syntactic alternative to proliferation of
default value options, so that
x = getattr(u, 'answer', 42)
can be written as
x = y.answer except ... 42
For a dictionary d,
x = d.get('answer', 42)
can be written as
x = d['answer'] except ... 42
For a list L,
try:
x = L[i]
except IndexError:
x= 42
can be written as
x = L[i] except ... 42
The ellipsis in the above stands for syntax being debated.
Effectively, Python is about to gain support for a new operator and
operators are very precious for numpy. So, I think numpy community has a
horse in that race.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140218/eef95ddf/attachment.html>
More information about the NumPy-Discussion
mailing list