← Back to team overview

fuel-dev team mailing list archive

Python discussion: format vs %

 

Hi,

I several times saw patches with comments that we should use format instead
of '%' for string formatting.

For example:

In [17]: 'some text {0}'.format('ololo')
Out[17]: 'some text ololo'

Instead of

In [16]: 'some text %s' % 'ololo'
Out[16]: 'some text ololo'

Nikolay, as I know you prefer (and most of this comments were from you)
first method, could you explain for all of us what is the difference? And
why we should use first method? And maybe we should add this info in some
of our docs?

Thanks.

Follow ups