Pypartial is a simple Python library that allows the use of partial function application notation in native Python. It is extremely useful when trying to write concise and clear code, and extends the ease offered by Python’s functional programming features.
Example:
import pypartial #use <_ notation to partial apply functions
binary = int<_(base=2) #you can pass keyword arguemnts print(binary(‘101010100101’))
import random dice=random.randint<_(1, 6) #you can also pass non-keywords print(dice()) print(dice())
up_to_ten = range<_(_, 11) #you can leave args blank with ‘_’ print(list(up_to_ten(5)))
import operator double = operator.mul<_(2) print(double(7))
- class Foo(object):
- def bar(self, a, b):
print([a,b])
- def egg(self, a, b, c=9):
print([a,b,c])
foo=Foo() bar7 = foo.bar<_(_, b=7) #works with methods too bar7(2)
egg1 = foo.egg<_(_, 5) egg2 = egg1<_(c=9) #you can partially apply multiple times egg2(6)
print(egg2) #nice string representation
Release files for pypartial 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pypartial-1.0.3.tar.gz | 6.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pypartial-1.0.3-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 9.8 kB
Release files / pypartial-1.0.3.tar.gz
| Download URL | pypartial-1.0.3.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
00f136d02ff67c3f3031fa6af7649a9f06d0b953e5906907e582d67dc6c37e9f
|
|
BLAKE2b-256 checksum How to use checksums |
4ad264ff730b41463f0bc972e2799a909015e6a72a4bffabddc77a10b4e6a544
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pypartial-1.0.3-py2.py3-none-any.whl
| Download URL | pypartial-1.0.3-py2.py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
0342efecf5a8dac280e3f2891acd780550b17ac9df7a8e2439c48a5ff4461fc9
|
|
BLAKE2b-256 checksum How to use checksums |
1a3a924cbdb4ca61e78befc4a647838a29de12bc1dde086a15dbe16da2a92dd7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |