Python3 - How do I import a class from another file

Antoon Pardon antoon.pardon at vub.be
Tue Dec 10 09:50:24 EST 2019


On 10/12/19 13:44, R.Wieser wrote:
> Chris,
>
>> Well, that's exactly what happens.
> So, only the reference count gets lowered.  Yep, thats daft.
>
> ... unless you explain why it can only be done that way.
>
>> Also, when you scorn something without knowing your facts,
>> you tend to make yourself look like a fool :)
> I tend to go with logic.   No logic => it most likely doesn't work that way.
>
> Choosing to go with a delayed action like you say will, as I already 
> explained, create problems later on (race conditions everywhere).  And as I 
> do not think the designers of the language where that stupid I must 
> therefore reject your claim to what you think happens.

Well yes that is why it is stupid to rely on the garbage collector to do
those things for you. That is why Greg Ewing already stated:

> If your object has a method for explicitly making it release its
> resources, it would be better to use that rather than rely on
> the garbage collector. 

> But, as you mentioned, I do not know (all) the facts.  Please do present 
> them.   Maybe there is a logic in there I do not yet see.

What would you want to happen in the following case:

   foo1 = Bar()
   foo2 = foo1
   del foo1

Should the object be cleaned up now or not?




More information about the Python-list mailing list