[New-bugs-announce] [issue1588] str.format() wrongly formats complex() numbers (Py30a2)

Mark Summerfield report at bugs.python.org
Tue Dec 11 14:30:51 CET 2007

New submission from Mark Summerfield:

>>> x = complex(1, 2/3)
>>> "{0} {0:.5}".format(x)
'(1+0.666666666667j) (1+0.'

The complex number is being formatted as if it were a string and simply
truncated to 5 characters. I would expect each part of the complex
number to be formatted according to the format specifier, i.e., in the
case of :.5 to both have 5 digits after the decimal point.

components: Interpreter Core
messages: 58428
nosy: mark
severity: normal
status: open
title: str.format() wrongly formats complex() numbers (Py30a2)
type: behavior
versions: Python 3.0

Tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list