builtin functions for and and or?

Diez B. Roggisch deetsNOSPAM at web.de
Sun Feb 13 16:04:26 EST 2005


> So usually I just write a little function any( L, boolean_function =
> identity ) or all( ... ).  But I am kind of sick of doing that all the
> time -- does it exist anywhere in the Python libraries?  It seems really
> common to me.

Put things into your own module and add it to your python path. Then you
only have to write it once. 
 
> The first way isn't satisfactory because it takes so many lines for what
> is
> essentially one "primitive" operation.  The second way isn't great because
> it is not as readable and many readers don't like to see reduce, even if
> it
> is a common idiom like that.  Also I don't believe it short circuits.

It doesn't but so doesn't your loop example. Put a break in there once
Result is False.

-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list