Typed pipe
Project description
Tipe - typed pipe
Tipe allows you to create constructions similar to pipe operator, where result of a function used as an input of next function
Examples
>>> from tipe import Pipe
>>>
>>> Pipe(2).pipe(lambda x: x + 1).pipe(float).unwrap()
3.0
>>> Pipe([2, 3, 4]) \
... .pipe(len) \
... .pipe(lambda x: x + 1) \
... .pipe(float) \
... .unwrap()
4.0
Equivalent for examples above would be
>>> float(2+1)
3.0
>>> float(len([2, 3, 4]) + 1)
4.0
API
Pipe()
To use .pipe()
on a value wrap it with Pipe
class
>>> Pipe(2)
Pipe(2)
Pipe.pipe()
Pass function to execute on Pipe
value. Wraps function result in Pipe
and returns it
Pipe.check()
Like Pipe.pipe()
but does not change the value inside Pipe
. May be useful for debugging purposes
>>> Pipe(2).pipe(lambda x: x ** x).check(print).pipe(float).unwrap()
4
4.0
Pipe.unwrap()
Returns value from Pipe
Short forms
For convenience you can use P
as short version of Pipe
and short versions of the methods:
p
:pipe
c
:check
u
:unwrap
Types
tipe
tries its best to stay typesafe, so every function knows what exactly what it returns as long as it is inferable from arguments
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file tipe-1.0.0.tar.gz
.
File metadata
- Download URL: tipe-1.0.0.tar.gz
- Upload date:
- Size: 2.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.0 CPython/3.11.2 Linux/5.15.0-1033-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4bcb0ca8f352c0135a4c41ae0d7fb17a2054d1a586d9489a288a8bb38da98f78 |
|
MD5 | 5c1b6eccac8ce85000c5cb5dce98aab8 |
|
BLAKE2b-256 | 910757d51004e687f4717769a5881487c49d52fdad7f587694593bf8798094ef |
File details
Details for the file tipe-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: tipe-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.0 CPython/3.11.2 Linux/5.15.0-1033-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2013c857dea9d3c7bd7004902114f09a1011071036a53b40686391a61e0c04f |
|
MD5 | 046698e1ed01519305f113ff12a30732 |
|
BLAKE2b-256 | 7f1687412d5ba82bc7aec7292e78af3ba9f26461f7bc4f644d1861400480869a |