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 10/12/19 16:10, Chris Angelico wrote:
> On Wed, Dec 11, 2019 at 1:53 AM Antoon Pardon <antoon.pardon at vub.be> wrote:
>> 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?
>>
> TBH both are plausible,

I find that strange because if you cleanup the object in that scenario
it should also
be cleaned up in the following.

    def newbar():
        foo = Bar
        return foo

    bar = newbar()

foo goes out of scope, so that is equivallent to a del foo. But I wouldn't
want the object cleaned up because of that.

-- 
Antoon Pardon.