class_docstr: Inherit from this class and define ``__nice__`` to "nicely" print your
  objects.
  
  Defines ``__str__`` and ``__repr__`` in terms of ``__nice__`` function
  Classes that inherit from :class:`NiceRepr` should redefine ``__nice__``.
  If the inheriting class has a ``__len__``, method then the default
  ``__nice__`` method will return its length.
  
  Example:
      >>> class Foo(NiceRepr):
      ...    def __nice__(self):
      ...        return 'info'
      >>> foo = Foo()
      >>> assert str(foo) == '<Foo(info)>'
      >>> assert repr(foo).startswith('<Foo(info) at ')
  
  Example:
      >>> class Bar(NiceRepr):
      ...    pass
      >>> bar = Bar()
      >>> import pytest
      >>> with pytest.warns(None) as record:
      >>>     assert 'object at' in str(bar)
      >>>     assert 'object at' in repr(bar)
  
  Example:
      >>> class Baz(NiceRepr):
      ...    def __len__(self):
      ...        return 5
      >>> baz = Baz()
      >>> assert str(baz) == '<Baz(5)>'
class_docstr_tok: ["Inherit","from","this","class","and","define","``","__nice__","``","to","``","nicely","''","print","your","objects",".","Defines","``","__str__","``","and","``","__repr__","``","in","terms","of","``","__nice__","``","function","Classes","that","inherit","from",":","class",":","`","NiceRepr","`","should","redefine","``","__nice__","``",".","If","the","inheriting","class","has","a","``","__len__","``",",","method","then","the","default","``","__nice__","``","method","will","return","its","length",".","Example",":",">",">",">","class","Foo","(","NiceRepr",")",":","...","def","__nice__","(","self",")",":","...","return","'info'",">",">",">","foo","=","Foo","(",")",">",">",">","assert","str","(","foo",")","==","'","<","Foo","(","info",")",">","'",">",">",">","assert","repr","(","foo",")",".startswith","(","'","<","Foo","(","info",")","at","'",")","Example",":",">",">",">","class","Bar","(","NiceRepr",")",":","...","pass",">",">",">","bar","=","Bar","(",")",">",">",">","import","pytest",">",">",">","with","pytest.warns","(","None",")","as","record",":",">",">",">","assert","'object","at","'","in","str","(","bar",")",">",">",">","assert","'object","at","'","in","repr","(","bar",")","Example",":",">",">",">","class","Baz","(","NiceRepr",")",":","...","def","__len__","(","self",")",":","...","return","5",">",">",">","baz","=","Baz","(",")",">",">",">","assert","str","(","baz",")","==","'","<","Baz","(","5",")",">","'"]
docstr: str: a "nice" summary string describing this module
docstr_tok: ["str",":","a","``","nice","''","summary","string","describing","this","module"]
code: def __nice__(self):
      """str: a "nice" summary string describing this module"""
      if hasattr(self, "__len__"):
          # It is a common pattern for objects to use __len__ in __nice__
          # As a convenience we define a default __nice__ for these objects
          return str(len(self))
      else:
          # In all other cases force the subclass to overload __nice__
          raise NotImplementedError(
              f"Define the __nice__ method for {self.__class__!r}"
          )
  
imports: import warnings
label_desc: Use image node_id 1 for calling the NiceRepr obj's underlying member method code with example usage: obj.__nice__() and returns: str