4 ms·
To be clear about the `del block` thing, the only thing that the `del` keyword does in Python is unbind a name from the local scope. It does not cause an object
by Jasper_ 9y ago
To be clear about the `del block` thing, the only thing that the `del` keyword does in Python is unbind a name from the local scope. It does not cause an object to be destructed, call `__del__`, or anything else. It's morally equivalent to "block = None", except future references to block will raise a NameError instead of giving you None.
When used at the end of a function, when all locals go out of scope, it is actually doing nothing.
- ben-schaaf 9y agoUnbinding a name does do one thing which might call `__del__`: It decreases the reference count by 1.