Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tombulled/sentinel
Implementation of the Sentinel Object Pattern
https://github.com/tombulled/sentinel
python sentinel
Last synced: 23 days ago
JSON representation
Implementation of the Sentinel Object Pattern
- Host: GitHub
- URL: https://github.com/tombulled/sentinel
- Owner: tombulled
- License: mit
- Created: 2021-10-22T21:44:57.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-08-13T20:16:00.000Z (over 2 years ago)
- Last Synced: 2023-03-05T18:53:58.267Z (almost 2 years ago)
- Topics: python, sentinel
- Language: Python
- Homepage: https://pypi.org/project/literally/
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sentinel
Implementation of the Sentinel Object Pattern## Prelude
Come voice your opinions on [PEP-661](https://www.python.org/dev/peps/pep-0661/) (adding sentinels to the standard library) at [Discussions on Python.org](https://discuss.python.org/t/pep-661-sentinel-values/9126)## Usage
### Standard API
```python
import sentinelclass NotFound(sentinel.Sentinel): pass
``````python
>>> NotFound
NotFound
```### Functional API
```python
import sentinelUnspecified = sentinel.Sentinel('Unspecified')
``````python
>>> Unspecified
Unspecified
```### Custom Sentinels
```python
import sentinelclass SentinelMeta(sentinel.SentinelMeta):
def __repr__(self) -> str:
return f'<{type(self).__name__}>'class Sentinel(SentinelMeta, metaclass=SentinelMeta): pass
class Example(Sentinel): pass
``````python
>>> Example```