Multiple -m command line arguments (Python)
arguments, command-line, python
Solution
It is not possible to start two modules using two `-m` arguments. This is because the command line arguments after `-m` are all given to the named module as `sys.argv`. This is not described explicitly in the documentation but you can try it out experimentally.
Create two python files `a.py` and `b.py`.
Contents of `a.py`:
print 'a'
import sys
print sys.argv
Contents of `b.py`:
print 'b'
Now try to run both using two `-m` arguments:
$ python -m a -m b
Output:
a
['/home/lesmana/tmp/a.py', '-m', 'b']
As you can see module b is never started because the second `-m` is not handled by python. It is given to module a to handle.
Problem
I want to run both cProfiler (For time measurement, mainly) and also a memory profiler that I found here. However, both require the -m command line argument to be given, which doesn't exactly play nicely. Is there a way to have both running? All I've managed to do so far is get the interpreter yelling at me. If you need any more information, let me know and I'll do my best to provide it. Thanks in advance!