0

I want to be able to dynamically change the value of a variable of a Python program outside of the program from another Python program. I have this function:

def main():
    PATH = 'path/to/file'

Is there a way to edit this variable from another Python program? The only way I can think of is sharing a text file between the two files, one inputs into it, one extracts from it.

KSHMR
  • 741
  • 1
  • 9
  • 24

1 Answers1

0

You indeed need to make configuration file. You can write some kind of parser for your .py file, search for desired string and edit it, but that's something I would not recommend you to do (take a look at this question).
For 'text file' solution take a look at ConfigParser

Community
  • 1
  • 1
arbulgazar
  • 1,931
  • 1
  • 19
  • 24