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

Chris Angelico rosuav at gmail.com
Mon Jan 25 12:36:56 EST 2016


On Tue, Jan 26, 2016 at 4:31 AM, Ian Kelly <ian.g.kelly at gmail.com> 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 some_list has three elements. I wouldn't expect it to fail
> just because the middle element is unused, so why should it fail if
> there are trailing elements that are unused?

That's using selectors, so under my suggested semantics, that would
still work - as long as it has *at least* three elements, the middle
one and any extras after the third are all ignored.

ChrisA



More information about the Python-list mailing list