Showing content from http://mail.python.org/pipermail/python-dev/attachments/20161103/f0076c53/attachment.html below:
<div dir="ltr">Stephen, dropwhile(None, ...) was an example, takewhile(None, ...) doesn't works either and it makes a lot of sense IMO.</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 3, 2016 at 7:07 AM, Stephen J. Turnbull <span dir="ltr"><<a href="mailto:turnbull.stephen.fw@u.tsukuba.ac.jp" target="_blank">turnbull.stephen.fw@u.tsukuba.ac.jp</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Francisco Couzo writes:<br>
<br>
 > I'd be interested in writing a patch to make itertools more consistent if<br>
 > there's a consensus.<br>
<br>
</span>I don't understand what you mean by "consistent". I would argue that<br>
in Python, an argument of None means "use the TOOWTDI default". For<br>
"filterfalse", bool() is pretty obvious for the default predicate<br>
since most Python classes do have a boolean interpretation. For<br>
"groupby", I guess the identity is the "intuitive" default. But for<br>
dropwhile, bool() or the identity seem like obvious choices, but<br>
intuitively they're not very useful since the head of what's left is a<br>
false-y. When would you want that? Typically false-ies are "nothing<br>
to see here, people, move along" values. I guess that consideration<br>
suggest lambda x: not(x), but I don't see why one would want to spell<br>
that dropwhile(None, ...) rather than dropwhile(not, ...), especially<br>
since in many contexts what you might really want (and expect None to<br>
default to) is dropwhile(lambda x: x is None, ...).<br>
<br>
Bottom line for me is that this use (and non-use) of None is consistent<br>
with Python practice regarding defaults.<br>
<br>
So, "accepts None" vs "doesn't accept None" doesn't seem to me to be<br>
an important enough consistency to impose unobvious semantics on<br>
dropwhile(None, ...).<br>
<br>
</blockquote></div><br></div>
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4