File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -463,6 +463,22 @@ should be your preferred method.
463
463
foo += ' ooo' # This is bad, instead you should do:
464
464
foo = ' ' .join([foo, ' ooo' ])
465
465
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
+ foo = ' foo'
475
+ bar = ' bar'
476
+
477
+ foobar = ' %s%s ' % (foo, bar) # It is OK
478
+ foobar = ' {0}{1} ' .format(foo, bar) # It is better
479
+ foobar = ' {foo}{bar} ' .format(foo = foo, bar = bar) # It is best
480
+
481
+
466
482
Vendorizing Dependencies
467
483
------------------------
468
484
You can’t perform that action at this time.
0 commit comments