0

I have a Python script called a.py, which takes 1 parameter from the command line. a.py is invoked as follows: python a.py 1, where 1 is the parameter value. Now, suppose I run a.py with 3 different parameter values on a single machine like this:

python a.py 1 &
python a.py 2 &
python a.py 3

I only see one a.pyc file. I wonder why there is only one a.pyc file since I invoke the program 3 times with 3 different parameters values, should there be 3 a.pyc files (maybe with different names)? If not, the a.pyc file couldn't contain all 3 parameters values, so where are the parameter values (i.e., 1,2,3) stored?

user131379
  • 321
  • 4
  • 9
  • 1
    `a.pyc` doesn't store any parameters passed to the program... (This can actually be a vulnerability as then anything you pass as a parameter, maybe something malicious, will be written to this file.) Why would you expect Python to create 3 copies of this file? It creates one `a.pyc` and then runs it with different arguments. – ForceBru Dec 24 '17 at 17:04
  • why do you want to run it 3 times? do you want to give 3 params as input to a single file? – Pankaj Singhal Dec 24 '17 at 17:04

1 Answers1

0

please refer this Difference py and pyc

Basically parameters you are passing is just a system argument. When Py file is get compiled it converted into Byte Code, Where System argument is just a input parameter from command line so there will be single Pyc file for the same code base.

Vardhman Patil
  • 517
  • 6
  • 22
  • OK but if I modify `a.py` and run it simultaneously with the first script (the original `a.py`), then the first script would produce erroneous output, yes? Since I think after we run the modified `a.py`, the `a.pyc` is changed which affects the first script. – user131379 Dec 30 '17 at 23:49