Could you explain to me what the difference is between calling
python -m mymod1 mymod2.py args
and
python mymod1.py mymod2.py args
It seems in both cases mymod1.py is called and sys.argv is
['mymod1.py', 'mymod2.py', 'args']
So what is the -m switch for?
The first line of the
Rationalesection of PEP 338 says:So you can specify any module in Python’s search path this way, not just files in the current directory. You’re correct that
python mymod1.py mymod2.py argshas exactly the same effect. The first line of theScope of this proposalsection states:With
-mmore is possible, like working with modules which are part of a package, etc. That’s what the rest of PEP 338 is about. Read it for more info.