If someone uses a python builtin as a variable, deleting the variable seems to revert the definition of the term to the original definition. For example:
set = 1
print(set)
del set
a = set([1,2,3])
print(a)
Result:
1
{1, 2, 3}
However, when you delete a builtin from the start, it is no longer defined:
del set
a = set([1,2,3])
print(a)
Result:
NameError: name 'set' is not defined
I understand that it is bad practice to use builtins as variables, but I'm curious about this design decision:
If the python source code can intelligently restore deleted variables by assigning them to their original builtin value, why does the code allow the deletion of builtins in my second example? What possible utility could there be in allowing the deletion of builtins?
No I don't have a real world use case for this; I just want to understand the design decision.