Mailing List Archive

run .py not in PATH
#!/usr/bin/env python
"""
The .py you want to run is in the python path but not
in your shell path.

I know everyone but me already has this problem solved
in a better way than this. If so please show me the way.

Assuming this is runIt.py then
runIt.py someScript.py arg1 arg2
"""
import sys
import imp

fp, pathname, description = imp.find_module(sys.argv[1])
sys.argv=sys.argv[2:]
md=imp.load_module('__main__', fp, pathname, description)
run .py not in PATH [ In reply to ]
From: "Darrell" <news@dorb.com>

#!/usr/bin/env python
"""
The .py you want to run is in the python path but not
in your shell path.

I know everyone but me already has this problem solved
in a better way than this. If so please show me the way.

Assuming this is runIt.py then
runIt.py someScript.py arg1 arg2
"""
import sys
import imp

fp, pathname, description = imp.find_module(sys.argv[1])
sys.argv=sys.argv[2:]
md=imp.load_module('__main__', fp, pathname, description)