Author mark
Recipients gvanrossum, mark
Date 2007-12-12.08:22:15
SpamBayes Score 0.0140698
Marked as misclassified No
Message-id <200712120819.49647.mark@qtrac.eu>
In-reply-to <1197395801.26.0.835562491899.issue1588@psf.upfronthosting.co.za>
Content
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 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'

That's not quite right because it doesn't always handle the sign
correctly and doesn't force float output. So I think it should be this:

'1.00000+0.66667j'
>>> "{0.real:.5f}{0.imag:+.5f}j".format(complex(1, -2/3))
'1.00000-0.66667j'
History
Date User Action Args
2007-12-12 08:22:15marksetspambayes_score: 0.0140698 -> 0.0140698
recipients: + mark, gvanrossum
2007-12-12 08:22:15marklinkissue1588 messages
2007-12-12 08:22:15markcreate