Re: .format won't display my value with 2 decimal places: Why?

2016-01-25 Thread Ian Kelly
On Sun, Jan 24, 2016 at 2:20 PM, MRAB wrote: > The format method, on the other hand, belongs to the format string it's > attached to. In this example: > > 'The new price is {}' .format(newPrice, '.2f') > > the format string is 'The new price is {}' and you're

Re: .format won't display my value with 2 decimal places: Why?

2016-01-25 Thread Chris Angelico
On Tue, Jan 26, 2016 at 3:51 AM, Ian Kelly wrote: > On Sun, Jan 24, 2016 at 2:20 PM, MRAB wrote: >> The format method, on the other hand, belongs to the format string it's >> attached to. In this example: >> >> 'The new price is {}'

Re[2]: .format won't display my value with 2 decimal places: Why?

2016-01-25 Thread MRAB
On 2016-01-25 16:51:36, "Ian Kelly" wrote: On Sun, Jan 24, 2016 at 2:20 PM, MRAB wrote: The format method, on the other hand, belongs to the format string it's attached to. In this example: 'The new price is {}' .format(newPrice,

Re: .format won't display my value with 2 decimal places: Why?

2016-01-25 Thread Chris Angelico
On Tue, Jan 26, 2016 at 4:32 AM, Random832 wrote: > On Mon, Jan 25, 2016, at 12:23, Chris Angelico wrote: >> if some translations don't use a token at all, > > I'm not sure what situation that would be reasonable in. I don't do much with different human languages, but

Re: Re[2]: .format won't display my value with 2 decimal places: Why?

2016-01-25 Thread Chris Angelico
On Tue, Jan 26, 2016 at 4:31 AM, Ian Kelly wrote: >> Do you really want to insist that the format string always used _all_ of the >> arguments? > > Good point, that makes sense. For example, I would expect this to work: > > '{0} {2}'.format(*some_list) > > as long as

Re: .format won't display my value with 2 decimal places: Why?

2016-01-25 Thread Random832
On Mon, Jan 25, 2016, at 12:19, MRAB wrote: > Do you really want to insist that the format string always used _all_ of > the arguments? Um, yes? Why on earth _wouldn't_ you want to insist that? -- https://mail.python.org/mailman/listinfo/python-list

Re: Re[2]: .format won't display my value with 2 decimal places: Why?

2016-01-25 Thread Ian Kelly
On Mon, Jan 25, 2016 at 10:19 AM, MRAB wrote: > > > On 2016-01-25 16:51:36, "Ian Kelly" wrote: > >> >> Why doesn't str.format raise an exception when passed extra positional >> arguments? >> > That format string uses auto-numbering, and it's

Re: .format won't display my value with 2 decimal places: Why?

2016-01-25 Thread Random832
On Mon, Jan 25, 2016, at 12:23, Chris Angelico wrote: > if some translations don't use a token at all, I'm not sure what situation that would be reasonable in. -- https://mail.python.org/mailman/listinfo/python-list

Re: .format won't display my value with 2 decimal places: Why?

2016-01-25 Thread Chris Kaynor
On Mon, Jan 25, 2016 at 9:48 AM, Chris Angelico wrote: > On Tue, Jan 26, 2016 at 4:32 AM, Random832 wrote: > > On Mon, Jan 25, 2016, at 12:23, Chris Angelico wrote: > >> if some translations don't use a token at all, > > > > I'm not sure what situation

.format won't display my value with 2 decimal places: Why?

2016-01-24 Thread Michael Sullivan
Hi. I'm very very new to python. I have been working my way through a free python pdf file I found (python3handson.pdf) and I'm having trouble with one of my programs: '''discount.py Exercise 1.14.3.1. * Write a program, discount.py, that prompts the user for an original price and for a

Re: .format won't display my value with 2 decimal places: Why?

2016-01-24 Thread MRAB
On 2016-01-22 04:57:03, "Michael Sullivan" wrote: Hi. I'm very very new to python. I have been working my way through a free python pdf file I found (python3handson.pdf) and I'm having trouble with one of my programs: '''discount.py Exercise 1.14.3.1. * Write a