You set the difference in import statements. This is partly a question of the namespace for which the object will be imported, as well as a way to limit the exact amount of imported code.
import os from os import path
Both os and os.path are modules. The first imports the entire os module and all its submodules. This may be more than you need, and for large libraries overhead may be unnecessary. Although you can still access the path through os.path
The second form is a way to selectively import a path module. Also, instead of entering your code under the os
namespace, it is now at the root level as soon as path
.
So far, this link Import Script from the parent directory tells you everything you need to know, here is one more specific information:
Then your various scripts can reference another module in relation to the main folder, for example:
from ui_sub_direcotory import menu from domain_sub_directory import domain import main
These are all valid imports within your package.
source share