File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -463,6 +463,23 @@ should be your preferred method.
463463 foo += ' ooo' # This is bad, instead you should do:
464464 foo = ' ' .join([foo, ' ooo' ])
465465
466+ .. note ::
467+ You can also use the **% ** formatting operator to concatenate the
468+ pre-determined number of strings besides **join() ** and **+ **. However,
469+ according to `PEP 3101 <http://www.python.org/dev/peps/pep-3101/ >`_,
470+ **% ** operator became deprecated in Python 3.1 and will be replaced by the
471+ **format() ** method in the later versions.
472+
473+ .. code-block :: python
474+
475+ foo = ' foo'
476+ bar = ' bar'
477+
478+ foobar = ' %s%s ' % (foo, bar) # It is OK
479+ foobar = ' {0}{1} ' .format(foo, bar) # It is better
480+ foobar = ' {foo}{bar} ' .format(foo = foo, bar = bar) # It is best
481+
482+
466483 Vendorizing Dependencies
467484------------------------
468485
You can’t perform that action at this time.
0 commit comments