Special Method Protocols
__trunc__() — numeric protocol
Return truncation toward zero; math.trunc delegates for non-float objects.
Formal Syntax & Structure
python syntaxpython
def __trunc__(self):Return Value
Integral
Rounded or integral result specified by the hook.
Working Example
Example Snippetpython
import mathclass Number: def __init__(self, value): self.value = value def __trunc__(self): return math.trunc(self.value)print(math.trunc(Number(-3.75)))