Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 11b6362

Browse files
committed
#7495: more review fixes.
1 parent 1427869 commit 11b6362

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

Doc/faq/programming.rst

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ Note that the functionally-oriented builtins such as :func:`map`, :func:`zip`,
182182
and friends can be a convenient accelerator for loops that perform a single
183183
task. For example to pair the elements of two lists together::
184184

185-
>>> list(zip([1,2,3], [4,5,6]))
185+
>>> list(zip([1, 2, 3], [4, 5, 6]))
186186
[(1, 4), (2, 5), (3, 6)]
187187

188188
or to compute a number of sines::
@@ -192,14 +192,16 @@ or to compute a number of sines::
192192

193193
The operation completes very quickly in such cases.
194194

195-
Other examples include the ``join()`` and ``split()`` methods of string objects.
195+
Other examples include the ``join()`` and ``split()`` :ref:`methods
196+
of string objects <string-methods>`.
197+
196198
For example if s1..s7 are large (10K+) strings then
197199
``"".join([s1,s2,s3,s4,s5,s6,s7])`` may be far faster than the more obvious
198200
``s1+s2+s3+s4+s5+s6+s7``, since the "summation" will compute many
199201
subexpressions, whereas ``join()`` does all the copying in one pass. For
200-
manipulating strings, use the ``replace()`` and the ``format()`` methods on
201-
string objects. Use regular expressions only when you're not dealing with
202-
constant string patterns.
202+
manipulating strings, use the ``replace()`` and the ``format()`` :ref:`methods
203+
on string objects <string-methods>`. Use regular expressions only when you're
204+
not dealing with constant string patterns.
203205

204206
Be sure to use the :meth:`list.sort` builtin method to do sorting, and see the
205207
`sorting mini-HOWTO <http://wiki.python.org/moin/HowTo/Sorting>`_ for examples
@@ -414,8 +416,8 @@ It's good practice if you import modules in the following order:
414416

415417
Never use relative package imports. If you're writing code that's in the
416418
``package.sub.m1`` module and want to import ``package.sub.m2``, do not just
417-
write ``from . import m2``, even though it's legal. Write ``from package.sub import
418-
m2`` instead. See :pep:`328` for details.
419+
write ``from . import m2``, even though it's legal. Write ``from package.sub
420+
import m2`` instead. See :pep:`328` for details.
419421

420422
It is sometimes necessary to move imports to a function or class to avoid
421423
problems with circular imports. Gordon McMillan says:
@@ -860,7 +862,7 @@ To convert, e.g., the number 144 to the string '144', use the built-in type
860862
constructor :func:`str`. If you want a hexadecimal or octal representation, use
861863
the built-in functions :func:`hex` or :func:`oct`. For fancy formatting, see
862864
the :ref:`string-formatting` section, e.g. ``"{:04d}".format(144)`` yields
863-
``'0144'`` and ``"{:.3f}" % (1/3)`` yields ``'0.333'``.
865+
``'0144'`` and ``"{:.3f}".format(1/3)`` yields ``'0.333'``.
864866

865867

866868
How do I modify a string in place?

0 commit comments

Comments
 (0)