Skip to content

Instantly share code, notes, and snippets.

@wwitzel3
Created January 25, 2011 23:45
Show Gist options
  • Save wwitzel3/795949 to your computer and use it in GitHub Desktop.
Save wwitzel3/795949 to your computer and use it in GitHub Desktop.
Is this a horrible idea?
>>> class Booltring(object):
... def __nonzero__(self):
... return False
... def __str__(self):
... return 'X'
...
>>> b = Booltring()
>>> bool(b)
False
>>> print b
X
>>> if b:
... print b
...
>>> if not b:
... print b
...
X
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment