Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #32086

Re: simple string format question

From Piet van Oostrum <piet@vanoostrum.org>
Newsgroups comp.lang.python
Subject Re: simple string format question
Date 2012-10-24 23:48 -0400
Message-ID <m27gqfkya5.fsf@cochabamba.vanoostrum.org> (permalink)
References <k5guje$ui$1@ger.gmane.org> <mailman.2200.1350305892.27098.python-list@python.org>

Show all headers | View raw


Adrien <adnothing@gmail.com> writes:

> print "{:.3g}".format(2.356)  # this rounds up

But:

>>> print "{:.3g}".format(12.356) 
12.4
>>> print "{:.3g}".format(123.356) 
123

-- 
Piet van Oostrum <piet@vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: simple string format question Adrien <adnothing@gmail.com> - 2012-10-15 14:58 +0200
  Re: simple string format question Piet van Oostrum <piet@vanoostrum.org> - 2012-10-24 23:48 -0400
    Re: simple string format question Neil Cerutti <neilc@norwich.edu> - 2012-10-25 12:49 +0000

csiph-web