Python3 - How do I import a class from another file

R.Wieser address at not.available
Sun Dec 8 11:29:20 EST 2019


Hello all,

Using Python3 I would like to import a specific class from another file (in 
the same folder), and have trouble doing so.

"from file import function" works, but fails when I try to do the same with 
a class.

"import file
x = file.class"

works, but also executes commands that are in the root of the file. And 
ofcourse loads all of the file, not just the class that I'm after ...

In other words, what is the syntaxt I should use ?

Regards,
Rudy Wieser




More information about the Python-list mailing list