+ 1
Doubt about del statement in Python
If a string variable is deleted with the del statement, what happens to the string contained in the now deleted variable?
2 Respuestas
+ 3
del deletes the reference. When the value is garbage-collected (deleted), depends on the implementation. It may be erased right away or later – given that the data is not referenced otherwise, of course.
https://stackoverflow.com/a/1481512
0
I never found the need to del a string variable. Using del on a variable makes it invalid unless a new value is assigned to it. Python is garbage collected, so memory allocation and deallocation is abstracted away.
The more common use of del is for list items.
courses = ["Python","Java","C++"]
del courses[1]