I work with the financial exchange API. I need to perform three actions 1) Once to make an action, a purchase 2) Get data about this action 3) Work with this data on a cycle, once a minute, for an hour

I would like to do this with two functions.

def action(): my_action = ... my_data = .... return my_data def info(data): for _ in range (60): my_info = data * 2 print (my_info) info(data=action()) 

In principle, it works, the action is performed once, and info - many times, but this record looks somehow not logical, and if you add more variables, then everything can become complicated. There are more correct, logical methods for my task.

  • I recommend reading about code refactoring and design patterns. Perhaps there is what you need - aeiklorvy
  • Passing the result of one function as a parameter to another is quite normal. - Pavel Durmanov 6:51 pm
  • Make multiple threads Threading Module Manual - Dospayne2 4:04 pm

0