+ 13
Can anyone explain the 6th and 7th lines?
7 Respuestas
+ 13
Because they all make sense and I can not understand these two.
+ 5
Python counts how often a data item is referenced so it knows the memory can be reused. By assigning a two times, it has a reference count of 3. By updating the variables in 6 and 7 to new values, they no longer reference the 42 so the count is decremented. Together with the delete of a, the reference count becomes 0 and the memory is available for reuse.
+ 5
Putting on my moderator hat, since you don't know this, you must not have coded this. You are required to credit the original author or web site for any code you make public on this site. This is true no matter how little of the original is left. Please either give proper credit or make this code private. Thank you!
+ 4
No, that just removes one reference so the count is 2 as both b and c still use it.
+ 4
Here is an example using classes. Note there is only one constructor and destructor printout and the destructor is called on delete of b.
https://code.sololearn.com/czi6GltHa04I
+ 3
Got it John! Thank you very much. :)
+ 2
I have a follow up question for John about this then. The count does not go to 0 the moment we do del a? After such a statement does it still matter that at some point we had b = a?