__del__ is not called after creating a new reference
steve+python at pearwood.info
Mon Mar 20 13:57:38 EDT 2017
On Tue, 21 Mar 2017 04:51 am, Steve D'Aprano wrote:
> On Sat, 18 Mar 2017 01:54 am, Oleg Nesterov wrote:
>> However, this trivial test-case
> I cannot confirm that test case. When I try it, I get NameError:
Ah, never mind! I was running this in the interactive interpreter, and
forgot that it saves a reference to the last result using _ so of course
the __del__ method didn't run at all.
I changed the code to run:
c = C()
and now I'm seeing the same thing as you: DEL is only printed once.
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
More information about the Python-list