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!
To pass command line arguments, we typically define main() with two arguments : first argument is the number of command line arguments and second is list of command-line arguments. The value of argc should be non negative. argv(ARGument Vector) is array of character pointers listing all the arguments.
Python Command line arguments are input parameters passed to the script when executing them. Almost all programming language provide support for command line arguments. Then we also have command line options to set some specific options for the program.
It stores the number of the command line arguments passed by a user from the terminal and also stores the name of the program. The value of argc must not be negative. argv:- It is a pointer array and it points to every argument which is being passed to the program. Argv[0] denotes the name of the program.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With