Kai
Kai

Reputation: 993

How to change value of the variable in one python script from another python script

I have to files python1 and python2.

Python2.py has code something like this:

import sys
variable1=value1
variable2=value2
#and some python code from here on

The python1 script should take the input value for variable1 and variable2 and change the corresponding value in python2.py without tampering the other code.

And example 2: If any user gives the variable1 value as android. The value of variable1 in python2 should be changed to android

Thanks

Note: python2 is not a configuration file, has many other modules

Upvotes: 1

Views: 1647

Answers (1)

Jon Clements
Jon Clements

Reputation: 142216

You can just import python2 in python1, then use python2.variable1=...

Upvotes: 3

Related Questions