unbuiltins
Thoroughly tested and MyPy compatible constants and functions you'd expect to find in the Python builtins.
Install
requires python 3.8 or higher
pip install unbuiltins
Usage
from unbuiltins import *
Missing
Like the constant None, Missing can be used for e.g. optional function
arguments:
def say(value: Missable[str] = Missing):
if value is Missing:
print('*silence*')
else:
print(value)
frozendict
The builtins include frozenset, but frozendict is nowhere to be found
(see PEP 416).
frozendict is basically an immutable and hashable dict:
assert frozendict(spam='spam') == dict(spam='spam')
assert {frozendict(): 'empty'}[frozendict()] == 'empty'
It accepts generic type arguments and supports the merge (|) operator,
like dict since Python 3.9:
def add_eggs(value: frozendict[str, str]) -> frozendict[str, Union[str, int]]:
return value | dict(eggs=6)
assert 'eggs' in add_eggs(frozendict(spam='spam'))
first
Behaves identical to next, but works for all iterables:
assert first([42, 666, 69]) == 42
assert first([], default='empty') == 'empty'
assert first(iter(dict(eggs=6))) == 'eggs'
filternone
Return those items of iterable that are not None:
assert list(filternone(['', None, 0, False])) == ['', 0, False]
either
Returns the first argument that is not None or Missing:
assert either(None, None, False) is False
Release files for unbuiltins 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| unbuiltins-0.2.2.tar.gz | 17.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| unbuiltins-0.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 34.4 kB
Release files / unbuiltins-0.2.2.tar.gz
| Download URL | unbuiltins-0.2.2.tar.gz |
|---|---|
| Size | 17.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a890382a5d0d24b0f510953123265c34f3e0c542ac33d8fea7379eac2ab2e1ac
|
|
BLAKE2b-256 checksum How to use checksums |
910ab4abafa6bc120a3e10832f574649edf0255e3ef007fd1a601dbdc9f87994
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5
|
Release files / unbuiltins-0.2.2-py3-none-any.whl
| Download URL | unbuiltins-0.2.2-py3-none-any.whl |
|---|---|
| Size | 17.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c696aebf9d6fd50bac64c51e47126f7cbde6122e4d458b8594cd3bbc038498b7
|
|
BLAKE2b-256 checksum How to use checksums |
564ce6bc439980d112955a37e476314b3978ad2999c79767db04099bfcd90aad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5
|