>>> print(decimal.Decimal(23) / decimal.Decimal("1.05"))
21.90476190476190476190476190
>>> decimal.Decimal(23) / decimal.Decimal("1.05")
Decimal('21.90476190476190476190476190')
When print()
is called on the result of decimal.Decimal(23) / decimal.Decimal("1.05")
the raw number is printed; this output is in string form which can be achieved with __str__()
. If we simply enter the expression we get a decimal.Decimal
output — this output is in representational form which can be achieved with __repr__()
. All Python objects have two output forms. String form is designed to be human-readable. The representational form is designed to produce output that if fed to a Python interpreter would (when possible) reproduce the represented object.