returning True, False or None

nghoffma nghoffma at gmail.com
Fri Feb 4 22:20:25 EST 2005


Is it cheating to use a Set?

py>>def doit(thelist):
...     s = sets.Set(thelist)
...     if s == sets.Set([None]):
...             return None
...     else:
...             return max(s)
...
py>>print doit([ True , None , None , False ] )
True
py>>print doit([ None , False , False , None ] )
False
py>>print doit([ False , True , True , True ] )
True
py>>print doit( [None, None, None, None] )
None




More information about the Python-list mailing list