Musings & ramblings of a Pythonista
People are often confused about Python's del
keyword and __del__()
method.
Most people think that applying del
on an object causes the object's
__del__()
method to be called. But this is not true. del
keyword merely
decrements the objects reference count and de-scopes the variable on its
application. But it doesn't necessarily invoke the object's __del__()
method.
__del__
method will be called only when the garbage ...
Have you ever noticed any difference between variables in Python and C? For example, when you do an assignment like the following in C, it actually creates a block of memory space so that it can hold the value for that variable.
int a = 1;
You can think of it as putting the value assigned in a box with the variable name as shown below.
And for all the variables ...