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

Mark Summerfield report at bugs.python.org
Wed Dec 12 08:42:45 CET 2007


Mark Summerfield added the comment:

On 2007-12-11, Guido van Rossum wrote:
> Guido van Rossum added the comment:
>
> This really is a feature request -- in Python 2.x there is no formatting
> code for complex numbers at all, and "%.5s" % complex(...) does the same
> thing.

I thought Python 3 was meant to be an _improvement_:-)

> I agree it would be neat to have control over complex numbers using the
> same formatting language used for floats; but I note that it's easy
> enough to do this manually, e.g.
>
> >>> "{0.real:.5}+{0.imag:.5}j".format(z)
>
> '1+0.66667j'

Good point, I'll use that.

Thanks!

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1588>
__________________________________


More information about the Python-bugs-list mailing list