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

Method __nice__

util/utils.py:356–365  ·  view source on GitHub ↗

str: a "nice" summary string describing this module

(self)

Source from the content-addressed store, hash-verified

354 >>> assert str(baz) == '<Baz(5)>'
355 """
356 def __nice__(self):
357 """str: a "nice" summary string describing this module"""
358 if hasattr(self, '__len__'):
359 # It is a common pattern for objects to use __len__ in __nice__
360 # As a convenience we define a default __nice__ for these objects
361 return str(len(self))
362 else:
363 # In all other cases force the subclass to overload __nice__
364 raise NotImplementedError(
365 f'Define the __nice__ method for {self.__class__!r}')
366
367 def __repr__(self):
368 """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