1

I have a project structured like this:

Folder A
    Folder B
        b.py
        __init__.py
    Folder C
        c.py
        __init__.py
__init__.py

I want to import c.py from b.py, is there any way I can do this without:

  • Moving any of the files
  • Using absolute paths ("C\Users...c.py")

Thank you so much.

guppythegod
  • 63
  • 1
  • 6
  • 1
    Possible duplicate of [Import from sibling directory](https://stackoverflow.com/questions/4542352/import-from-sibling-directory) – jpp Feb 21 '18 at 23:49

1 Answers1

0

I assume this is part of a larger project. You should run python <script name> from the parent directory of Folder A. Then you can do

import A.C.c

or

from A.C import c
Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268