Good day all. Maybe there is something I don't understand. How can I get the output of my console to change by just changing a variable in this case a, b or c. Without reloading the console. I either get it to output once and then I have a blinking prompt or it prints massive amount of lines. Here is my test:
a = 1
b = 1
c = 1
print(a, b, c)
def messenger():
while a and b and c:
print("True")
else:
print("False")
time.sleep(5)
So if I change variables: a,b or c in the script, save the file, then just observe the console for a change. Any help would be greatly appreciated.
Since a,b,c are variables they are stored in memory that is allocated to the script during run time.
you can't change those values without re-running the script, which will freeup the old memory, reallocate new memory, and run your code.
I suspect your need for implementing such a solution, changing vars like this; will be way more work than you'll be comfortable implementing (the solution to this can be intermediate project on its own)
you are better of reading values into these vars from a file or db.
with open('filefora.txt', 'r') as f:
a = int(f.readline())
with open('fileforb.txt', 'r') as f:
b = int(f.readline())
while True:
if a and b:
print(True)
else:
print(False)
with open('filefora.txt', 'r') as f:
a = int(f.readline())
with open('fileforb.txt', 'r') as f:
b = int(f.readline())
Now every time you change the value in the file for the respective var, the code will use that new value without having to rerun the script.
Even better would be to just rerun the file.