xxx222 xxx222 - 1 year ago 81
Python Question

How to call functions in python files that are not in the working directory?

Say now my working folder is

and my supporting python files are in
, I want to call a function
in the
file under
, what should I do? I tried calling
from supporting_files.a import func
and that does not work. How am I suppose to do that without changing the actual working directory?

Answer Source

Add an file (it can be empty) to the supporting_files directory, and python will treat it as a package available for imports. More details are available in the Python documentation.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download