class Node(str): """ Node class for directed graph library. Extends string so you can use the Node object itself to read it's label. """ def __new__(cls, label, object): new_node = super().__new__(cls, label) new_node._object = object return new_node def get_object(self): return self._object