Replace nested function calls with chaining expression
Project description
chaintools
Function chaining
chaintools.F
를 활용해 함수를 연결하는 할 수 있다.
def add(tar: int) -> Callable[[int], int]:
def _wrapper(src: int) -> int:
return src + tar
return _wrapper
f = F >> add(1) >> add(2)
assert f(3) == 6
함수의 반환 형태가
Tuple[Tuple, Dict[str, Any]]
형태일때 다음 함수의*args, **kwargs
에 값을 넣어줄 수 있다.
def function1() -> Tuple[Tuple, Dict[str, Any]]:
return (1, 2), {'c': 1, 'd': 2}
def function2(a, b, c, d) -> int:
return a + b + c + d
f = F >> function1 >> function2
assert f() == 6
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
chaintools-0.0.1.tar.gz
(3.5 kB
view hashes)
Built Distribution
Close
Hashes for chaintools-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 067b24118cd1707b743dc1a69f050711565db168b66a1217435799a4ef2b1b5c |
|
MD5 | 7f5e36b4cd103c97fa2cf59236794f17 |
|
BLAKE2b-256 | ccaf604dd348b47eb9f1a689fdb6a2be77f1c0dc8f24480ba48ac9464da6ac3b |