ironpython - Python: sys.path.append vs. import? -
i have (single) .py script. in it, need import library.
in order library found, need call sys.path.append. however, not want hardcode path library, pass parameter.
so problem if make function (set_path) in file, need import file, , import fails because path not yet appended.
what ways solve problem?
clarification after comments:
- i using ironpython, , library path path cpython/lib. path (potentially) different on every system.
- as far know, cannot pass via sys.argv, because script run in embedded python interpreter, , there no main function.
maybe pass file argument using sys.argv, add path , import it. run program this:
python my_program.py somefolder/some_import.py
here's reference using sys.argv: http://www.pythonforbeginners.com/systems-programming/python-sys-argv/