'Import update in Python
So I want to import * from a phyton file. However, these variables I want to import are connected to an API. So they change.
For instance: at 3:35 is A=5 at 3:36 is A=6
So I want my import to be done every 15 second. How do I write this?
Solution 1:[1]
Just use it this way where I just show the schedule to show how the variables can be changed in two files and the schedule represented the change of the API.
In the file1.py
import schedule
import time
def job(t):
var1=5
print(var1)
schedule.every().day.at("3:35").do(job,'It is 3:35')
while True:
schedule.run_pending()
time.sleep(15) # wait one minute
In the file2.py
from file1 import var1
import schedule
import time
def job(t):
var1=6
print(var1)
schedule.every().day.at("3:36").do(job,'It is 3:36')
while True:
schedule.run_pending()
time.sleep(15) # wait one minute
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
