[issue1588] str.format() wrongly formats complex() numbers (Py30a2)

Mark Dickinson report at bugs.python.org
Tue Apr 28 12:26:42 CEST 2009


Mark Dickinson <dickinsm at gmail.com> added the comment:

> Complex would be the first one. But that doesn't really bother me.

It bothers me a little.  I see '' as a special case of the empty
presentation type, even if that's not what a strict reading of
PEP 3101 says, so I expect '', '>' '<20' all to format the
number in the same way, and only differ in their treatment of
alignment and padding.  That is, adding a '>' to the start of a
format specifier shouldn't change the formatting of the number
itself.  So from this perspective, it seems better if format(x, '')
ends up doing the same thing as str(x) as a result of the
choices made for the empty presentation type, rather than
as a result of special-casing ''.

> Although I guess if we wanted to, we could say that the empty 
> presentation type is equivalent to 'g', but gives you parens.

This works for me.

[about suppressing real zeros...]
> Again, we could say that the empty presentation type is 
> different in this regard.

Makes sense.  Does treating the empty presentation type as special this
way add much extra complication to the implementation?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1588>
_______________________________________


More information about the Python-bugs-list mailing list