[Tutor] True/False evaluations?
kent37 at tds.net
Wed Dec 1 17:57:52 CET 2004
No, I actually tried that first. operator.or_ is a bitwise or, not a logical or. IOW,
is the same as
a | b
a or b
which is what I needed. There doesn't seem to be an equivalent to 'a or b' in the operator module.
Blake Winton wrote:
> Kent Johnson wrote:
>> >>> if reduce(lambda x, y: x or y, [ , 0, None ]):
>> ... print 'do something'
>> ... else:
>> ... print 'nothing to do'
>> nothing to do
>> lambda x, y: x or y
>> just gives us a function that applies logical or to its arguments.
> You could use operator.or_ for the same thing, but without needing to
> explain lambda. ;) (I recently did some exploring in that territory,
> and came across it.)
More information about the Tutor