19th November 2021
Coding⚑
Python⚑
asyncio⚑
-
New: Limit concurrency.
Use
asyncio.Semaphore
.sem = asyncio.Semaphore(10) async with sem: # work with shared resource
Python Snippets⚑
-
New: Remove a substring from the end of a string.
On Python 3.9 and newer you can use the
removeprefix
andremovesuffix
methods to remove an entire substring from either side of the string:url = 'abcdc.com' url.removesuffix('.com') # Returns 'abcdc' url.removeprefix('abcdc.') # Returns 'com'
On Python 3.8 and older you can use
endswith
and slicing:url = 'abcdc.com' if url.endswith('.com'): url = url[:-4]
Pydantic⚑
-
New: Field customization.
Optionally, the
Field
function can be used to provide extra information about the field and validations. Such as thetitle
,default
,description
and many others
Tenacity⚑
-
New: Introduce the Tenacity python library.
Tenacity is an Apache 2.0 licensed general-purpose retrying library, written in Python, to simplify the task of adding retry behavior to just about anything.