Supply condition in function call

Chris Angelico rosuav at gmail.com
Thu Mar 26 02:00:33 EDT 2015


On Thu, Mar 26, 2015 at 3:02 PM, Rustom Mody <rustompmody at gmail.com> wrote:
> [And BTW
> help(filter) in python2 is much better documention than in python3
> ]

Python 2.7.3 (default, Mar 13 2014, 11:03:55)
[GCC 4.7.2] on linux2

filter(...)
    filter(function or None, sequence) -> list, tuple, or string

    Return those items of sequence for which function(item) is true.  If
    function is None, return the items that are true.  If sequence is a tuple
    or string, return the same type, else return a list.

Python 3.5.0a0 (default:4709290253e3, Jan 20 2015, 21:48:07)
[GCC 4.7.2] on linux

class filter(object)
 |  filter(function or None, iterable) --> filter object
 |
 |  Return an iterator yielding those items of iterable for which function(item)
 |  is true. If function is None, return the items that are true.
 |
 |  Methods defined here:
(chomp a handful of method details)

Looks pretty comparable to me. Py2 clearly stipulates that it's a
function that returns a tuple, string, or list. Py3 defines it as a
class, and then describes what it does (it's an iterator) and then its
methods.

ChrisA



More information about the Python-list mailing list