Python3 - How do I import a class from another file
On 2019-12-10 17:18, R.Wieser wrote:
>> Okay. What should happen when you do this?
>> x = 5
>> del x
>> Should the integer 5 be deleted?
> What do you think happens instead ? I've not seen you explain or support
> anything in that regard, not even now.
> There is a bit of a problem with the above though: It has got zero to do
> with the __del__ I was talking about. I've not seen you point out any
> mistake with my example (pointing out race contition problems) either.
> Not a smooth move bro. Not a smooth move /at all/ :-(
>> So the language designers couldn't possibly have been so stupid
>> as to do things this way, but you're going to ignore what they did?
> Actually, they didn't.
> Did you know you can disable the garbage collector ? Well, you can. Guess
> what I saw when I disabled it, created a class instance and than deleted it
> again. Yup, the "print" command I placed in the "__del__" method did
> actually show output - something that, according to you, could/should never
> happen ...
> Than again, I've used Python 3 for the test. Maybe you're remembering
> something from an older version ?
You merely disabled the mark-and-sweep collector.
When the reference out reaches zero, the object is deleted, but if an
object is part of a reference cycle, the reference count will never
To deal with that, there's a mark-and-sweep collector that's called