Right now I have some code that looks like this:
userinput1 = abc.....
userinput2 = abc.....
userinput3 = abc.....
async def task1():
do something with userinput1...
do another thing...
async def task2():
do something with userinput2...
do another thing...
async def task3():
do something with userinput3...
do another thing...
async def main():
await asyncio.wait([task1() , task2(), task3()])
if __name__ == '__main__':
asyncio.get_event_loop().run_until_complete(main())
As you can see above, I have 3 async functions that do separate things simultaneously. I was wondering if theres any way to easily create many functions based off of user input? Essentially what I want to have it be able to do is this:
userinput1 = abc.....
userinput2 = abc.....
userinput3 = abc.....
userinput4 = abc.....
amount_of_needed_functions = 4
And then once it had gotten that data it would run like this script:
async def task1():
do something with userinput1...
do another thing...
async def task2():
do something with userinput2...
do another thing...
async def task3():
do something with userinput3...
do another thing...
async def task4():
do something with userinput4...
do another thing...
async def main():
await asyncio.wait([task1() , task2(), task3(), task4()])
if __name__ == '__main__':
asyncio.get_event_loop().run_until_complete(main())
So pretty much it would make functions based off of certain veriables (such as userinput1) and then do this however many times specified (amount_of_needed_functions) and then run all of these simultaneously. Sorry this is a bit of confusing question but I'm quite lost as where to start researching this. Thanks!