[Tutor] True/False evaluations?

Kent Johnson 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,
   operator.or_(a, b)
is the same as
   a | b
not
   a or b
which is what I needed. There doesn't seem to be an equivalent to 'a or b' in the operator module.

Kent

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.)
> 
> Later,
> Blake.
> 
> 


More information about the Tutor mailing list