[PATCH] fix core library string formatting for python 2.6

Amitay Isaacs amitay at gmail.com
Fri Sep 21 03:49:29 UTC 2018

On Fri, Sep 21, 2018 at 11:33 AM, Douglas Bagnall via samba-technical
<samba-technical at lists.samba.org> wrote:
>> I will do the tests in another patch.
> Here.
> Please review with a bit of care: *one* way in which Python's .format()
> is inferior to its % printf formatting is there is no error for
> unconsumed arguments. That is, if I went:
> -    "{} {} {}".format(x, y, z)
> +    "{0} {1} {1}".format(x, y, z)
> there would be no error to say I had ignored the third argument.
> So you need to review my ability to count.

str.format() also accepts field names.  It might be overkill for
single argument format strings.  But for multiple arguments, it's
self-documenting if used with sensible field names.

"{0} {1} {2}"  ---> "{first-name} {middle-name} {last-name}"

And you also get argument checking as you need to pass the values by name.


More information about the samba-technical mailing list