True
Skip Montanaro
skip at pobox.com
Thu Aug 7 10:34:21 EDT 2003
Dan> Thanks Peter, that will do the trick. Just wondering though why you
Dan> chose to code the opposite values and not as
Dan> def boolean2String(boolVal):
Dan> return {True:'1', False:'0'}[boolVal]
What if boolVal isn't actually True or False? An empty list is considered a
false value. To get a boolean from that, you throw 'not' in front of it:
>>> []
[]
>>> not []
True
>>> not 23
False
Skip
More information about the Python-list
mailing list