sentinel.py 595 B

1234567891011121314151617181920
  1. """Sentinel class for constants with useful reprs"""
  2. # Copyright (c) IPython Development Team.
  3. # Distributed under the terms of the Modified BSD License.
  4. from __future__ import annotations
  5. class Sentinel:
  6. """Sentinel class for constants with useful reprs"""
  7. def __init__(self, name, module, docstring=None):
  8. """Initialize the sentinel."""
  9. self.name = name
  10. self.module = module
  11. if docstring:
  12. self.__doc__ = docstring
  13. def __repr__(self):
  14. """The string repr for the sentinel."""
  15. return str(self.module) + "." + self.name