Python3 - How do I import a class from another file

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Dec 11 19:47:49 EST 2019


On 12/12/19 3:50 am, R.Wieser wrote:
> I was rather clear about what my used version of Python was-and-is.  I have
> no idea why that was ignored. :-(

I think we've all been talking at cross purposes for a while.

What I meant to say originally was that you were relying on
an implementation detail of current CPython, and your code
might not work on other versions of Python. I was just
trying to make you aware of something that is considered
"best practice" when writing Python code, for your own
future reference.

However, you seem to have interpreted it as "this may not
work in current CPython". You were quite right to argue
against that, because it's false. But it didn't become
apparent that's what you were thinking until after quite
a lot of heated discussion.

The reason the discussion became heated is that instead of
saying "I don't understand", you said "I don't believe you".
This came across as arrogant and put everyone's back up.

> I have brought up that a delayed calling of the __del__
> method could/would most likely cause race problems.  Do you have any idea
> how thats solved in environents like Jython ?

You deal with it by not relying on __del__ for anything
that needs to be done promptly. There are always alternatives:
e.g. file objects have a close() method, and the "with"
statement was invented to make it easy to do these kinds
of things properly.

-- 
Greg


More information about the Python-list mailing list