Clear Variable In Python
Answer :
The del
keyword would do.
>>> a=1 >>> a 1 >>> del a >>> a Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'a' is not defined
But in this case I vote for self.left = None
What's wrong with self.left = None
?
var = None
"clears the value", setting the value of the variable to "null" like value of "None", however the pointer to the variable remains.
del var
removes the definition for the variable totally.
In case you want to use the variable later, e.g. set a new value for it, i.e. retain the variable, None
would be better.
Comments
Post a Comment