A small Python library that provides a singleton `Nil` object. This object is designed to represent missing or unset values in scenarios where `None` is a valid and meaningful data value, thus avoiding ambiguity. Currently at version 1.0.2, it's a stable, single-purpose library with infrequent updates.
pip install niltypeVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to import and use the `Nil` singleton to distinguish between a truly missing value (represented by `Nil`) and an intentional `None` value in a function's return, especially useful for API responses or configuration.
Always use identity checks (`if obj is Nil:` or `if obj is not Nil:`) when specifically checking for the `Nil` singleton. Avoid `if not obj:` if you need to distinguish `Nil` from other falsey values.
This is by design and fundamental to `niltype`. It implies `Nil` cannot carry state or attributes specific to a particular missing value context. If you need contextual information, wrap `Nil` in a custom class or use a different pattern.
Always check `if my_var is not Nil:` before attempting to access properties or methods on `my_var`, as `Nil` has no user-defined attributes.
Implement explicit checks for `Nil` and handle it appropriately (e.g., return early, provide a default value, raise a more specific exception) before passing the variable to type-sensitive operations. For example: `my_str = 'Default' if my_var is Nil else str(my_var)`.
No dependency data recorded yet.