true = 1
Mark McEahern
marklists at mceahern.com
Sat Jan 12 14:48:19 EST 2002
Daniel Dittmar wrote:
> +1
> except that I would prefer
> true = 'true'
> false = None
> because that would be more meaningful when used in print , %s etc.
I wasn't concerned about print, but in that case I'd suggest a full-bodied
class a la the one posted by Cromwell, Jeremy:
> class Boolean:
> def __init__(self, truth=1):
> self.truth = not not truth
> def __eq__(self, other):
> return self.truth != (not other)
> def __str__(self):
> return ["False","True"][self.truth]
> def __repr__(self):
> return "Boolean(%d)" % self.truth
> def __len__(self):
> return self.truth
>
> true = Boolean(1)
> false = Boolean(0)
Cheers,
// mark
More information about the Python-list
mailing list