repr2¶
Module Contents¶
- repr2.repr2(obj, rmtrailing0=False)¶
Produces the string representation of obj using str(obj).
This function calls str(obj) to produce a string representation of obj. Thus, obj can be any type, so long as __str__ is defined for obj.
Decimalobjects add a trailing ‘.’ if not already in the string representation. Can optionally remove trailing 0 if rmtrailing0 is True (i.e. 1.0 -> 1.).- Parameters:
- Returns:
The string representation for obj.
- Return type:
Example usage:
>>> from repr2 import repr2 >>> repr2(1.0) '1.0' >>> from decimal import Decimal >>> repr2(Decimal('1')) '1.' >>> repr2(Decimal('1.0')) '1.0' >>> repr2(1.0, rmtrailing0=True) '1.'