Articles → Python → Del Method In Python For Deleting Module From Default Namespace
Del Method In Python For Deleting Module From Default Namespace
Purpose
Click to Enlarge
- Math module is imported using import keyword. Math module is added in default namespace.
- Print the value of math.pi.
- Delete the module using del() method.
- Print the value of math.pi. This time, code will give an error as math module is removed from default namespace.
Using Del For Variables
temp = "This is temp variable"
# Print
print(temp)
#Delete
del(temp)
# Print (This method will give error)
print(temp)
Click to Enlarge