For a coding challenge, I made a small subclass of str
so I could store and extra attribute with a string:
class Node(str):
def __init__(self, s):
self.marked = False
def __bool__(self):
return self.marked
This way I could write Node('44')
and have something that compares equally with a str
but has a different truth value. l noticed though that I apparently don’t need to call super().__init__
in Node.__init__
for this to work. Why is that?