osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Python3 - How do I import a class from another file


On 2019-12-10 21:08, R.Wieser wrote:
> Chris,
> 
>> Once again, you make positive assertions about things you
>> don't understand.
> 
> And you have refused to bring any kind of help (explanation!) forward that
> could have shown me the erring of my ways, as well as refusing to adress my
> (attempting to explain) examples.
> 
> You might know a thing or two about Python, but you (and a number of others
> here) positivily stink as teachers, incapable or even unwilling to place
> themselves in the shoes of a newbie.
> 
> Only now I know, after Dennis explanation, that there are (at least) /two/
> garbage collectors.  One of which is triggered by a reference count becoming
> zero, and one periodically called.
> 
> And although you have been fighting me over when the __del__ method is
> called, it /is/ called directly as a result of an "del instance" and the
> refcount goes zero.  There is /no/ delay.    (with the only exception is
> when a circular reference exists).
> 
You don't "del" an instance, you "del" a reference, which might be in 
the form of a name in a namespace.

If that was the only reference to the instance, then the instance can be 
collected.

When the instance is collected, whenever that happens to be, its 
"__del__" method is called.

CPython uses reference counting, so if del removes the only reference, 
the instance will collected the instance immediately.

The language definition doesn't specify that reference counting must be 
used; that's just what CPython happens to use, and it's nice in that 
collection tends to happen sooner.

Other implementations can use other techniques, and for some of them 
there might be a delay before collection kicks in, so if an instance is 
holding a resource, that resource would not be released as quickly.

> Hence, no "race condition" problem.
> 
> But for some reason even my claiming that that would happen didn't trigger
> any kind of understanding.
> 
> And you  blame /me/ for making certain (logical!) assumptions ?   Really ?
>