What is the best way to make a variable that works exactly like a bool but prints On or Off rather than True or False? Currently the program is printing: Color: True, whereas Color: On would make more sense.
For the record, I initially tried to make an OnOff class that inherits from bool:
class OnOff(bool):
def __str__(self):
if self: return 'On'
else: return 'Off'
From the comments, I now understand that bool is a singleton, which is why this failed miserably:
Traceback (most recent call last):
class OnOff(bool):
TypeError: Error when calling the metaclass bases
type 'bool' is not an acceptable base type
print ("Off", "On")[value]works too (because(False, True) == (0,1))