Member-only story
Python: Standard Libraries you should use - Part 1
Gateway to Efficiency
Hi, Welcome to the another installment of my exploration into Python’s vast library ecosystem! In this segment, I will continue uncovering some of the coolest Python libraries that I think can enhance your projects and simply your development process.
Upgrade your python projects with descriptive understanding of powerful python libraries.
Let’s dive in —
1. async— await, task, asyncio
Coroutines allow asynchronous programming by pausing and resuming execution using the async and await keywords.
Example —
async def foo():
print("Inside func foo")async will create a wrapper around the function, when you call this function, it returns a coroutine object. If you try to print the function, it will throw error as we haven’t created async event-loop. We need to use asyncio.
asyncio.run(foo())
# o/p - Inside func fooasyncio created an event-loop and added this coroutine to the event loop.
Another example using await. Use await to execute a coroutine object.
Here you can use await keyword as you are inside async function.
