Re: [Numpy-discussion] except expression discussion on python-ideas

2014-02-19 Thread Robert Kern
On Wed, Feb 19, 2014 at 3:18 AM, Alexander Belopolsky ndar...@mac.com wrote:
 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

 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.

It's control flow, not an operator. I haven't seen a proposal that
would use any precious syntactic possibilities that numpy might want
to use for an operator.

-- 
Robert Kern
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] except expression discussion on python-ideas

2014-02-19 Thread Benjamin Root
So, this is kind of like Perl's unless?


On Tue, Feb 18, 2014 at 10:18 PM, Alexander Belopolsky ndar...@mac.comwrote:

 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.

 ___
 NumPy-Discussion mailing list
 NumPy-Discussion@scipy.org
 http://mail.scipy.org/mailman/listinfo/numpy-discussion


___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] except expression discussion on python-ideas

2014-02-18 Thread Alexander Belopolsky
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.
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion