returning True, False or None

Steve Juranich juranich at barbet.tucson.saic.com
Fri Feb 4 13:13:19 EST 2005


> This has a light code smell for me though -- can anyone see a simpler 
> way of writing this?

How's about:

def ntf(x, y):
     if x is None and y is None: return None
     if x == True or y == True: return True
     return False
# Then...
reduce(ntf, <list of stuff>)

You might need to make sure that you initialize your "reduce" call the
right way with the optional third argument.

HTH

-- 
Stephen W. Juranich
Science Applications Intl. Corp. (SAIC)
Tucson, AZ



More information about the Python-list mailing list