[Numpy-discussion] Issues to fix for 1.7.0rc2.
Wed Feb 6 08:27:58 CST 2013
On Wed, Feb 6, 2013 at 4:18 AM, Dag Sverre Seljebotn <
> On 02/06/2013 08:41 AM, Charles R Harris wrote:
> > On Tue, Feb 5, 2013 at 11:50 PM, Jason Grout
> > <firstname.lastname@example.org <mailto:email@example.com>>
> > On 2/6/13 12:46 AM, Charles R Harris wrote:
> > > if we decide to do so
> > I should mention that we don't really depend on either behavior (we
> > probably should have a better doctest testing for an array of None
> > values anyway), but we noticed the oddity and thought we ought to
> > mention it. So it doesn't matter to us which way the decision goes.
> > More Python craziness
> > In : print None or 0
> > 0
> > In : print 0 or None
> > None
> To me this seems natural and is just how Python works? I think the rule
> for "or" is simply "evaluate __nonzero__ of left operand, if it is
> False, return right operand".
> The reason is so that you can use it like this:
> x = get_foo() or get_bar() # if get_foo() returns None
> # use result of get_bar
> def f(x=None):
> x = x or create_default_x()
And what if the user passes in a zero or an empty string or an empty list,
or if the return value from get_foo() is a perfectly valid zero? This is
one of the very few things I have disagreed with PEP8, and Python in
general about. I can understand implicit casting of numbers to booleans in
order to attract the C/C++ crowd (but I don't have to like it), but what
was so hard about "x is not None" or "len(x) == 0"?
I like my languages explicit. Less magic, more WYSIWYM.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion