[Python-ideas] all, any - why no none ?

Oscar Benjamin oscar.j.benjamin at gmail.com
Tue Apr 10 17:49:01 CEST 2012

none looks similar to None.

The code below rightly gives a NameError. If none were a builtin function,
not only would it allow the bug below but it would evaluate to True.

>>> def f(x=none):
...     if x:
...         do_stuff()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'none' is not defined

On Tue, Apr 10, 2012 at 4:22 PM, Steven Samuel Cole <
steven.samuel.cole at gmail.com> wrote:

> hello,
> i'm aware they've been around for quite a while, but for some reason, i
> did not have the builtins all(seq) and any(seq) on the radar thus far. when
> i used them today, i just assumed there was a corresponding none(seq), but
> was surprised to learn that is not true.
> why is that ? has this been considered ? discussed ? dismissed ? i did
> search, but the net being neither case-sensitive nor semantic, the results
> were off topic.
> sure, i can do not all or not any or any of these:
> http://stackoverflow.com/q/**6518394/217844<http://stackoverflow.com/q/6518394/217844>
> http://stackoverflow.com/q/**3583860/217844<http://stackoverflow.com/q/3583860/217844>
> but none(seq): True if all items in seq are None
> would IMHO be the pythonic way to do this.
> what do you think ?
> # ssc
> ______________________________**_________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/**mailman/listinfo/python-ideas<http://mail.python.org/mailman/listinfo/python-ideas>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20120410/f4ca9861/attachment.html>

More information about the Python-ideas mailing list