String formatting style

Stéfan van der Walt stefan at sun.ac.za
Wed Sep 3 05:57:35 EDT 2014


On Wed, Sep 3, 2014 at 1:20 AM, Michael Aye <kmichael.aye at gmail.com> wrote:
> It's part of the Python tutorial for many years and common standard I'd say.
> It's basic use might be cumbersome at first, but its power is great.
>
> Things like "My name is {0[name]}".format(dict(name='Fred'))

With great power comes great responsibility!  I find the above very
close to unreadable.

Compare to:

"My name is %s" % name

or

"My name is %(name)s" % {'name': 'Fred'}

Stéfan



More information about the scikit-image mailing list