For example, when I have such a Node class defined.
class Node:
def __init__(self, val=None, next=None):
self.val = val
self.next = next
def __bool__(self):
return self.val is not None
When I initialize it with empty arguments, like below. Is there a way to self-define method to say a is None?
a = Node()
a is None # False, but can it be true if I want?
None.Nonebefore every method call.__bool__method will allow you to writeif a:andif not a:is Noneto be true? What actually is aNode, and what are you planning to do with these Nodes?