0

So i want to import a script in other folder on the same directory level.

It's like this:

project
   ├── src
         ├── basic - __init__.py
         └── physics - __init__.py

I want to import a class from basic file, into the physics file.

Edit

I settled to just rename this files to basic.py and physics.py and placed them in the same folder so the directory looks like this now:

project
   ├── src
         ├── basic.py
         └── physics.py
martineau
  • 119,623
  • 25
  • 170
  • 301
CraXell
  • 11
  • 2
  • Could you please edit the directory diagram? It's hard to see what is where. Is physics folder in basic folder? – tornikeo Sep 06 '20 at 14:46
  • @tornikeo I edited it. its on the same level they are both in the src folder – CraXell Sep 06 '20 at 14:56
  • Just add the regular `__init__.py` file to basic folder and then type `from .basic import MyClass`. Does that help? Also add the `__init__.py` file to src folder. – tornikeo Sep 06 '20 at 14:57
  • 1
    Does this answer your question? [How to import the class within the same directory or sub directory?](https://stackoverflow.com/questions/4142151/how-to-import-the-class-within-the-same-directory-or-sub-directory) – Tomerikoo Sep 06 '20 at 14:59
  • @tornikeo I solved it but it was a bit of misunderstanding. Thanks for help anyways. – CraXell Sep 06 '20 at 15:13

0 Answers0