from directly_package.directlyfolder1 import a.py //a.py is in directly folder1
from directly_package.directlyfolder2 import b.py
print(folder1.function()) //Function execution
print(folder2.function())
Below is the contents of the files in the directory folder and the path specification. It is necessary to change the path specification depending on the conditions.
from directly_package.directly folder import utils //Absolute path
def x(): //Any function definition x
return'x'
def y():Let y be the definition of any function
return utils.z('y') //utils.The def defined in py.Described in return utils as z
Exception handling example
try:
from directly_package import utils
except ImportError:
from directly_package import utils
utils.any_function('word')
Create setup.py and try to create your own library.
Recommended Posts