falsifierยถ
๐ญ A very simple Python library package which provides a base class for
falsey objects - objects that evaluate to False in boolean contexts.
Installation ๐ฆยถ
Install via uv pip
command:
uv pip install falsifier
Or, install via pip:
pip install falsifier
Examples ๐กยถ
The Falsifier class provides a base for creating objects that evaluate to
False in boolean contexts:
>>> from falsifier import Falsifier
>>> obj = Falsifier( )
>>> bool( obj )
False
Identity-based equality ensures each instance is only equal to itself:
>>> obj2 = Falsifier( )
>>> obj == obj2
False
>>> obj == obj
True
Subclass to create domain-specific falsey types:
>>> class AbsentValue( Falsifier ):
... ''' Represents an explicitly absent value. '''
... def __str__( self ) -> str:
... return 'absent'
>>> absent = AbsentValue( )
>>> bool( absent )
False
See documentation/examples/objects.rst for more patterns, including singletons and collection usage.
Use Cases ๐ฏยถ
๐ฉ Sentinel Objects: Base class for creating unique sentinel objects that evaluate to
False.๐ณ๏ธ Absence Indicators: Foundation for creating objects that represent absence or invalidity when
NoneorFalsemay be valid.
Contribution ๐คยถ
Contribution to this project is welcome! However, it must follow the code of conduct for the project.
Please file bug reports and feature requests in the issue tracker or submit pull requests to improve the source code or documentation.
For development guidance and standards, please see the development guide.