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
Instalation
pip install tipe
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
>>> Pipe(2).pipe(range, 4).pipe(len).unwrap()
2
Equivalent for examples above would be
>>> float(2+1)
3.0
>>> float(len([2, 3, 4]) + 1)
4.0
>>> len(range(2, 4))
2
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 and additional params for it. 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:pipec:checku: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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tipe-1.1.0.tar.gz.
File metadata
- Download URL: tipe-1.1.0.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.7 Linux/6.2.0-1019-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
040277478f9c953dd77709f6b7b99effb1b456e5594ba9651f42442bc4d05a4d
|
|
| MD5 |
dec7c4a948661b8e4adf881ba8f3162d
|
|
| BLAKE2b-256 |
6ca3df3f34a38532afb8fc40e5a17a5c3104b2676a9bae7de1e8679d9b1c6246
|
File details
Details for the file tipe-1.1.0-py3-none-any.whl.
File metadata
- Download URL: tipe-1.1.0-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.7 Linux/6.2.0-1019-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40763195c7864abbbb47209e122ccb4c8c175f9934fbebadf26b1f516c7823e5
|
|
| MD5 |
f1e3049a7fa44869e3984a1ced6addb6
|
|
| BLAKE2b-256 |
9b770b3a12f960c2fd40935a7be1abfd13f43ef4faa600a4b2a31b9360abc137
|