Advertisement
Guest User

Untitled

a guest
Jul 24th, 2021
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. # you need to set this manually!
  2. __EXPECTED_PATH__ : str = 'foo.bar'
  3. if not (TYPE_CHECKING or (__name__ == __EXPECTED_PATH__)):
  4.     # if the script is not inside a module as expected,
  5.     # (such as if `__name__ == '__main__'`)
  6.     # (or if using a type checker)
  7.     # add to the path the directory which contains the package
  8.     sys.path.append(os.path.join(
  9.         sys.path[0],
  10.         '../' \* __EXPECTED_PATH__.count('.'),
  11.     ))
  12.  
  13. from foo.stuff import things,otherthings
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement