[Python-checkins] r76922 - python/branches/py3k/Doc/faq/programming.rst

georg.brandl python-checkins at python.org
Sun Dec 20 15:21:27 CET 2009

Author: georg.brandl
Date: Sun Dec 20 15:21:27 2009
New Revision: 76922

#7495: more review fixes.


Modified: python/branches/py3k/Doc/faq/programming.rst
--- python/branches/py3k/Doc/faq/programming.rst	(original)
+++ python/branches/py3k/Doc/faq/programming.rst	Sun Dec 20 15:21:27 2009
@@ -182,7 +182,7 @@
 and friends can be a convenient accelerator for loops that perform a single
 task.  For example to pair the elements of two lists together::
-   >>> list(zip([1,2,3], [4,5,6]))
+   >>> list(zip([1, 2, 3], [4, 5, 6]))
    [(1, 4), (2, 5), (3, 6)]
 or to compute a number of sines::
@@ -192,14 +192,16 @@
 The operation completes very quickly in such cases.
-Other examples include the ``join()`` and ``split()`` methods of string objects.
+Other examples include the ``join()`` and ``split()`` :ref:`methods
+of string objects <string-methods>`.
 For example if s1..s7 are large (10K+) strings then
 ``"".join([s1,s2,s3,s4,s5,s6,s7])`` may be far faster than the more obvious
 ``s1+s2+s3+s4+s5+s6+s7``, since the "summation" will compute many
 subexpressions, whereas ``join()`` does all the copying in one pass.  For
-manipulating strings, use the ``replace()`` and the ``format()`` methods on
-string objects.  Use regular expressions only when you're not dealing with
-constant string patterns.
+manipulating strings, use the ``replace()`` and the ``format()`` :ref:`methods
+on string objects <string-methods>`.  Use regular expressions only when you're
+not dealing with constant string patterns.
 Be sure to use the :meth:`list.sort` builtin method to do sorting, and see the
 `sorting mini-HOWTO <http://wiki.python.org/moin/HowTo/Sorting>`_ for examples
@@ -414,8 +416,8 @@
 Never use relative package imports.  If you're writing code that's in the
 ``package.sub.m1`` module and want to import ``package.sub.m2``, do not just
-write ``from . import m2``, even though it's legal.  Write ``from package.sub import
-m2`` instead.  See :pep:`328` for details.
+write ``from . import m2``, even though it's legal.  Write ``from package.sub
+import m2`` instead.  See :pep:`328` for details.
 It is sometimes necessary to move imports to a function or class to avoid
 problems with circular imports.  Gordon McMillan says:
@@ -860,7 +862,7 @@
 constructor :func:`str`.  If you want a hexadecimal or octal representation, use
 the built-in functions :func:`hex` or :func:`oct`.  For fancy formatting, see
 the :ref:`string-formatting` section, e.g. ``"{:04d}".format(144)`` yields
-``'0144'`` and ``"{:.3f}" % (1/3)`` yields ``'0.333'``.
+``'0144'`` and ``"{:.3f}".format(1/3)`` yields ``'0.333'``.
 How do I modify a string in place?

More information about the Python-checkins mailing list