I defined a class called Prof
in a script called AddPntCode90_27.py
. It opens some files, does some math, creates output files and so. Now I want to re-use the class for another programme. But as AddPntCode90_27.py
is not a module it always executes the script instead of just importing the class.
I did from AddPntCode90_27 import *
as well as from AddPntCode90_27 import Prof
.
I am familiar with this article. So my questions are:
- is it bad practice to define a class within a script like this? Should I always keep them in a separated file?
- is there, however, a way to import just the class and its methods without executing the script it is defined in?
Ah, I'm running Python 2.7.