Reputation: 71
can anybody help me please to make sure the API_Duplicate outside of the while loops only runs once?
My methodology is:
for while MarketIsActive == 'True'
to run continuously, listening for updates and assigning it to API_Data.
outside of the while loop, the API_duplicate = API_Data
only needs to execute the once to assign its value.
this allows the second while loop, while API_Duplicate != API_Data
to perform and take over the responsibility of assigning the API_duplicate = API_Data
within the loop itself.
while MarketIsActive == 'True':
API_data = 'API_endpoint'
API_duplicate = API_Data
while API_Duplicate != API_Data
API_duplicate = API_Data
# extra code
Thank you.
Upvotes: 1
Views: 49
Reputation: 4864
Put your code inside a class, have the class have a count variable, and assign API_duplicate
via a setter method, something like:
def set_dup(self):
if self.count < 1:
self.API_duplicate=self.API_data
self.count +=1
Upvotes: 1