Skip to main content

What you'd expect to find in the Python builtins

Project description


PyPI version

Thoroughly tested and MyPy compatible constants and functions you'd expect to find in the Python builtins.


requires python 3.8 or higher

pip install unbuiltins


from unbuiltins import *


Like the constant None, Missing can be used for e.g. optional function arguments:

def say(value: Missable[str] = Missing):
    if value is Missing:


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')) 


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'


Return those items of iterable that are not None:

assert list(filternone(['', None, 0, False])) == ['', 0, False]


Returns the first argument that is not None or Missing:

assert either(None, None, False) is False

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

unbuiltins-0.2.2.tar.gz (17.2 kB view hashes)

Uploaded source

Built Distribution

unbuiltins-0.2.2-py3-none-any.whl (17.2 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page