Calling python script from another directory -


i have python script base.py , having path username/packagename/base.py

another python script application.py, having path username/packagename/bin/application.py

how can call method of application.py base.py, since both being in different folder.

in bin directory, make empty file called __init__.py (two underscores on each side, total of 4 underscores). after doing that, python treat bin python module, , can do:

from bin import application # e.g. application.yourapplicationfunction(params) 

in base.py file.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -