Is there a way to clear the value of a variable in python?
For example if I was implementing a binary tree:
Class Node:
self.left = somenode1
I used a few options mentioned above :
del self.left
or setting value to None using
self.left = None
It's important to know the differences and put a few exception handlers in place when you use set the value to None. If you're printing the value of the conditional statements using a template, say,
print("The value of the variable is {}".format(self.left))
you might see the value of the variable printing "The value of the variable is None". Thus, you'd have to put a few exception handlers there :
if self.left:
#Then only print stuff
The above command will only print values if self.left is not None