I want to create a utility function that lets me schedule some arbitrary coroutine that can take some arbitrary number of arguments like this:
import asyncio
async def schedule(coro, *args, time_in_seconds=10):
await asyncio.sleep(time_in_seconds)
return await coro(args)
Doing some experiments in the python console gave me an error when I tried that on a function that takes two arguments. My guess is that *args
is turned into a list of values, which is treated as one singular parameter in the function call.
So my question is if it's possible to call a function with *args
as a parameter and have python treat the elements of the function as the parameters instead of the list *args