Ignore error with non-zero exit status (was: How to ignore error with anon-zero exit status)

Chris Angelico rosuav at gmail.com
Sun Dec 20 16:56:34 EST 2015


On Mon, Dec 21, 2015 at 8:22 AM, Thomas 'PointedEars' Lahn
<PointedEars at web.de> wrote:
> Python 2.6 (why are you using the oldest Python minor version?) introduced
> string.format(), so you should use that instead of the old string format
> operator (“%”):
>
>   logging.error("Can't run {0}; got {1} ({2:d})!".format(cmd, err, ret))
>
> <https://docs.python.org/2.6/library/stdtypes.html#str.format>

Percent formatting isn't going away. There's no need to tell people to
abandon it in favour of .format(), unless they actually need a feature
of .format().

> On the other hand, you do not need the format operator to begin with:
>
>   logging.error("Can't run %s; got %s (%d)!", cmd, err, ret)
>
> <https://docs.python.org/2.6/library/logging.html#logging.error>
>

See? Another good reason to hang onto percent formatting.

ChrisA



More information about the Python-list mailing list