osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Do not promote `None` as the first argument to `filter` in documentation.


On Wed, Mar 7, 2018 at 1:48 AM, Kirill Balunov <kirillbalunov at gmail.com> wrote:
> Note: For some historical reasons as the first argument you can use None
> instead of function, in this case the identity function is assumed. That
> is, all elements of iterable that are false are removed which is equivalent
> to (item for item in iterable if item). Currently, for the same purpose the
> preferred form is `filter(bool, iterable)`.
>

I'd prefer to word it something like:

If the first argument is None, the identity function is assumed. That
is, all elements of the iterable that are false are removed; it is
equivalent to (item for item in iterable if item). It is approximately
equivalent to (but faster than) filter(bool, iterable).

ChrisA