1

I have a directory which I would like to be the default for Python scripts so when a user is running python foo.py arg1 arg2 and foo.py is not in the current directory, it should execute python /defaultdir/foo.py arg1 arg2. Neither $PATH nor $PYTHONPATH is good for that: the first would only work with the command foo.py arg1 arg2, which requires a hashbang in the script and execution rights, while the second only works for import˙commands from an already running script. I suppose I could replace the Python binary with a wrapper, but I would prefer a cleaner solution if there was one.

2
  • 1
    I’m afraid what you want is unreasonable. Commented Sep 7, 2011 at 16:14
  • the last alternative (replacing python binary) seems to be the best you presented. Anyway you'll need to tinker with some system aspect or another. Commented Sep 7, 2011 at 16:15

1 Answer 1

2

Use python -m:

python -mfoo arg1 arg2
Sign up to request clarification or add additional context in comments.

2 Comments

did you mean python -m foo arg1 arg2?
Well color me impressed, it certainly looks like it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.