Hi all,

I have got several python scripts and I need to run them in one shot.
So I assume that in a .py file I can give statements ./file1.py
etc to run multiple scripts.
I am defining global variables in a config.py file and these will be shared by the 3 scripts(file1.py, file2.py and file3.py).
Now I need to use a parameter in each of the scripts : INITIAL_SOCKET_NUMBER = 10000.
So this needs to be part of the config file.
Now in the file1.py, I need to create 20 sockets. So INITIAL_SCOCKET_NUMBER + 20 would be final socket number. I then want to pass this value to the file2.py. file2.py should create and use 20 more sockets and it should pass INITIAL_SOCKET_NUMBER + 20 + 20 to file3.py.... and so on...
Could any one please tell me how to do this?


6 Years
Discussion Span
Last Post by prashanth s j

Not sure exactly what you're asking, but you can do it like this:

# file1.py

class File1:
    file1var = "Something"
# file2.py
from file1 import File1
# Do something to File1.file1var
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.