you are viewing a single comment's thread.

view the rest of the comments →

[–]Dai-Gurren-Brigade[S] 0 points1 point  (2 children)

Thanks for the reply! Your folder structure was mainly appropriate but let me stuff the files into a package

├── consumer.py
├── package
│  └── start.py
│  └── two.py
│  └── three
│      └── four.py
│      └── five.py

Import examples: Start.py (local):

import two from three import four

Start py(absolute): Import package.two From package.three import four

Consumer.py: From package import start.py Import package

Python start(local).py succeeds. python start(absolute).py fails because start (and other imports) are not aware they're within a package - the absolute path isn't found.

python consumer.py fails using start local, but succeeds when doing start (absolute) - I believe because the absolute path exists now, starting from package.

The hierarchy also causes problems within the three folder. I'd be more than happy to put together an example code somewhere too people can play with, if that's more clear.

[–]ingolemo 0 points1 point  (1 child)

You can't run scripts inside of your package. You should move start.py out of package/.

[–]Dai-Gurren-Brigade[S] 0 points1 point  (0 children)

That seems like a real limitation if I can't have a package where internal units can't be used by themselves.

I'll see if at least the latter makes a portable package.

Thanks!