- #1
- 2,168
- 193
I am working on Windows 10 and using VSCode.
In my project, the folder/file tree looks like this;
Now I want to import the classes in the metrictensor.py, riccitensor.py, riccitensor.py ... files into equation_producer.py
In this configuration, when I type
In equation_producer.py The code works.
However, the problem is that I have eight more files under \GRTensors. So I need to write something like
So that I don't have to write 10 imports.
In order to solve the problem, I have tried to create
in \Equations\__init__.py but it did not work (if I did not make a mistake/typo somewhere)
I have also tried to write.
In \Equations\__init__.py but it did not work as well.
So, how can I import all the classes into \Equations\equation_producer.py?
Note: Solutions that are modifiying __init__.py file are prefered.
In my project, the folder/file tree looks like this;
Code:
\Equations
__init__.py
equation_producer.py
\Objects
__init__.py
\GRTensors
__init__.py
metrictensor.py
riccitensor.py
riemanntensor.py
...
In this configuration, when I type
Code:
from Objects.GRTensors.metrictensor import MetricTensor
In equation_producer.py The code works.
However, the problem is that I have eight more files under \GRTensors. So I need to write something like
Code:
from Objects.GRTensors import *
So that I don't have to write 10 imports.
In order to solve the problem, I have tried to create
Code:
__all__ = ['metrictensor', 'riccitensor', 'riemanntensor'...]
in \Equations\__init__.py but it did not work (if I did not make a mistake/typo somewhere)
I have also tried to write.
Code:
from Objects.GRTensors.metrictensor import MetricTensor
from Objects.GRTensors.ricciscalar import RicciScalar
from Objects.GRTensors.riccitensor import RicciTensor
In \Equations\__init__.py but it did not work as well.
So, how can I import all the classes into \Equations\equation_producer.py?
Note: Solutions that are modifiying __init__.py file are prefered.
Last edited: