This library is designed to solve one of the most important problems in python programming - dividing all written code into 2 camps: sync and async. We get rid of code duplication by using templates.
Table of contents
Quick start
Install it:
pip install transfunctions
And use:
from asyncio import run from transfunctions import ( transfunction , sync_context , async_context , generator_context , ) @ transfunction def template (): print ( 'so, ' , end = '' ) with sync_context : print ( "it's just usual function!" ) with async_context : print ( "it's an async function!" ) with generator_context : print ( "it's a generator function!" ) yield function = template . get_usual_function () function () #> so, it's just usual function! async_function = template . get_async_function () run ( async_function ()) #> so, it's an async function! generator_function = template . get_generator_function () list ( generator_function ()) #> so, it's a generator function!
As you can see, in this case, 3 different functions were created based on the template, including both common parts and unique ones for a specific type of function.
You can also quickly try out this and other packages without having to install using instld.
The problem
... continue reading