Install executable package into a directory (example: /apps/my-app) instead of site-packages
1. Keep all statements, functions, classes in one module (your script !) . No relative imports is allowed.
2. function main() is not needed.
Package Python (package name maintained)
1. Keep the overall package layout flat. The package name is the only entry point of all module imports, use absolute imports only, sub-packages are generally accepted but not encouraged.
from mypackage.mymodule import myfunction
2. Expand sys.path in the module that contains main()
Package Python (package name not maintained)
1. Keep the overall package layout flat. Use relative imports (import from the same folder) only, sub-packages are generally accepted but not encouraged.
from mymodule import xxx
Coding scripts (temporary):
Put all definitions, variables, classes into one script; Or split them into several scripts if really needed (using relative import)
Coding non-trivial packages:
Split definitions, variables, classes into separate scripts; using absolute import, expand sys.path if needed.
- Interfaces cannot have typed parameters (dynamic typing nature), which raises troubles and confusions for the users (partial due to the lack of IDE support).
- Interfaces with a generics nature in dynamic typing system accepts arguments with different primitive types (root types). This complicates interface calls.