I study the code, and one of its lines confuses me:
things = [float(arg) for arg in sys.argv[1:]] Omega_a, Omega_b, Delta_a, Delta_b, \ init_pop_a, init_pop_b, tstep, tfinal = things
I searched online and tried to understand what sys.arg
means, and here is my understanding:
So sys.argv[0]
is the name of the file, and sys.argv[1:]
is the rest of the parameters that should be specified by users. I'm not sure I got it right, and if so, then I don’t understand why it doesn’t look like:
Omega_a = input() Omega_b = input() etc...
What is the difference between these two ways of providing parameters?
Also, if I run the code (press F5 ), the Python shell will report an error to me, for example:
Traceback (most recent call last): File "C:\Users\testcode.py", line 55, in <module> init_pop_a, init_pop_b, tstep, tfinal = things ValueError: need more than 0 values to unpack
I was not even given a chance to give parameters ( sys.argv[1:]
) before he gave me an error. Therefore, I searched the Internet. It seems like I need to run this code in cmd, which confused me even more, why is it needed and how do I put in cmd to run it?