MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / __nice__

Method __nice__

detrsmpl/utils/util_mixins.py:75–84  ·  view source on GitHub ↗

str: a "nice" summary string describing this module

(self)

Source from the content-addressed store, hash-verified

73 >>> assert str(baz) == '<Baz(5)>'
74 """
75 def __nice__(self):
76 """str: a "nice" summary string describing this module"""
77 if hasattr(self, '__len__'):
78 # It is a common pattern for objects to use __len__ in __nice__
79 # As a convenience we define a default __nice__ for these objects
80 return str(len(self))
81 else:
82 # In all other cases force the subclass to overload __nice__
83 raise NotImplementedError(
84 f'Define the __nice__ method for {self.__class__!r}')
85
86 def __repr__(self):
87 """str: the string of the module"""

Callers 2

__repr__Method · 0.95
__str__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected