Aug-21-2018, 08:30 AM
(This post was last modified: Aug-21-2018, 08:30 AM by ahmed_mokhles.)
Hello!
I am new to this forum so I hope I am posting in the right place.
I have a python program that creates another python file and declares 4 variables in it. How can I read the variables from the other file? Here is the first file "CodeTest.py":
Thanks
I am new to this forum so I hope I am posting in the right place.
I have a python program that creates another python file and declares 4 variables in it. How can I read the variables from the other file? Here is the first file "CodeTest.py":
import random testFile = open("testFile.py", "w+") testString = "abcd" for i in range(len(testString)): testRandom = random.randint(2048, 4096) testFile.write(str(testString[i] + " = " + str(testRandom) + "\n")) print("Variables declared in file testFile.py")and this is the file created "testFile.py":
a = 2316 b = 2498 c = 3607 d = 3290But now what do I add to CodeTest.py to be able to read the values in testFile.py?
Thanks