Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #109059 > unrolled thread
| Started by | Robin Becker <robin@reportlab.com> |
|---|---|
| First post | 2016-05-24 15:47 +0100 |
| Last post | 2016-05-24 15:47 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: str(float) python 3 versus 2.7 Robin Becker <robin@reportlab.com> - 2016-05-24 15:47 +0100
| From | Robin Becker <robin@reportlab.com> |
|---|---|
| Date | 2016-05-24 15:47 +0100 |
| Subject | Re: str(float) python 3 versus 2.7 |
| Message-ID | <mailman.55.1464101239.20402.python-list@python.org> |
On 23/05/2016 18:05, Ian Kelly wrote:
> On Mon, May 23, 2016 at 10:39 AM, Robin Becker <robin@reportlab.com> wrote:
.........
>
> If you want to show the float in a less noisy format, you can
> explicitly format it using the 'g' or 'n' presentation type, which
> essentially round to a given precision and strip off trailing zeros:
>
>>>> >>> '{:g}'.format(3*0.2)
> '0.6'
thanks; looking in 2.7 source I believe that the old float.__str__ behaved like
'%.12g' formatting. I can't imagine why people thought this was a 'good' idea
though.
--
Robin Becker
Back to top | Article view | comp.lang.python
csiph-web