Saturday, October 14, 2006

any and all built-in functions in Python 2.5

Oh! this is very nice:

$ python2.5
Python 2.5 (r25:51908, Sep 27 2006, 12:21:46)
[GCC 3.3.5 (Debian 1:3.3.5-13)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> any
built-in function any
>>> all
built-in function all
>>> print any.__doc__
any(iterable) -> bool

Return True if bool(x) is True for any x in the iterable.
>>> print all.__doc__
all(iterable) -> bool

Return True if bool(x) is True for all values x in the iterable.
>>> any([1,2])
True
>>> all([1,2])
True
>>> any([1,0])
True
>>> all([1,0])
False


Hey, I have made few edits here, (blame livejournal's `pre` tag), noticed it ? :)