Some cleanup in the docs.

This commit is contained in:
Georg Brandl 2007-12-29 10:57:00 +00:00
parent 28c7bcf38e
commit b19be571e0
126 changed files with 804 additions and 1181 deletions

View file

@ -75,8 +75,6 @@ Now that you are all excited about Python, you'll want to examine it in some
more detail. Since the best way to learn a language is to use it, the tutorial
invites you to play with the Python interpreter as you read.
.. % \section{Where From Here \label{where}}
In the next chapter, the mechanics of using the interpreter are explained. This
is rather mundane information, but essential for trying out the examples shown
later.

View file

@ -341,7 +341,7 @@ is called with this new argument list.
Random Remarks
==============
.. % [These should perhaps be placed more carefully...]
.. These should perhaps be placed more carefully...
Data attributes override method attributes with the same name; to avoid
accidental name conflicts, which may cause hard-to-find bugs in large programs,
@ -457,7 +457,7 @@ Derived classes may override methods of their base classes. Because methods
have no special privileges when calling other methods of the same object, a
method of a base class that calls another method defined in the same base class
may end up calling a method of a derived class that overrides it. (For C++
programmers: all methods in Python are effectively :keyword:`virtual`.)
programmers: all methods in Python are effectively ``virtual``.)
An overriding method in a derived class may in fact want to extend rather than
simply replace the base class method of the same name. There is a simple way to
@ -574,12 +574,10 @@ instance, if you have a function that formats some data from a file object, you
can define a class with methods :meth:`read` and :meth:`readline` that get the
data from a string buffer instead, and pass it as an argument.
.. % (Unfortunately, this
.. % technique has its limitations: a class can't define operations that
.. % are accessed by special syntax such as sequence subscripting or
.. % arithmetic operators, and assigning such a ``pseudo-file'' to
.. % \code{sys.stdin} will not cause the interpreter to read further input
.. % from it.)
.. (Unfortunately, this technique has its limitations: a class can't define
operations that are accessed by special syntax such as sequence subscripting
or arithmetic operators, and assigning such a "pseudo-file" to sys.stdin will
not cause the interpreter to read further input from it.)
Instance method objects have attributes, too: ``m.im_self`` is the instance
object with the method :meth:`m`, and ``m.im_func`` is the function object

View file

@ -31,11 +31,8 @@ example::
There can be zero or more :keyword:`elif` parts, and the :keyword:`else` part is
optional. The keyword ':keyword:`elif`' is short for 'else if', and is useful
to avoid excessive indentation. An :keyword:`if` ... :keyword:`elif` ...
:keyword:`elif` ... sequence is a substitute for the :keyword:`switch` or
:keyword:`case` statements found in other languages.
.. % Weird spacings happen here if the wrapping of the source text
.. % gets changed in the wrong way.
:keyword:`elif` ... sequence is a substitute for the ``switch`` or
``case`` statements found in other languages.
.. _tut-for:
@ -54,8 +51,8 @@ iteration step and halting condition (as C), Python's :keyword:`for` statement
iterates over the items of any sequence (a list or a string), in the order that
they appear in the sequence. For example (no pun intended):
.. % One suggestion was to give a real C example here, but that may only
.. % serve to confuse non-C programmers.
.. One suggestion was to give a real C example here, but that may only serve to
confuse non-C programmers.
::

View file

@ -400,7 +400,7 @@ combination of tuple packing and sequence unpacking!
There is a small bit of asymmetry here: packing multiple values always creates
a tuple, and unpacking works for any sequence.
.. % XXX Add a bit on the difference between tuples and lists.
.. XXX Add a bit on the difference between tuples and lists.
.. _tut-sets:

View file

@ -178,11 +178,9 @@ Reading and Writing Files
:func:`open` returns a file object, and is most commonly used with two
arguments: ``open(filename, mode)``.
.. % Opening files
::
>>> f=open('/tmp/workfile', 'w')
>>> f = open('/tmp/workfile', 'w')
>>> print f
<open file '/tmp/workfile', mode 'w' at 80a0960>

View file

@ -219,8 +219,8 @@ setting an environment variable named :envvar:`PYTHONSTARTUP` to the name of a
file containing your start-up commands. This is similar to the :file:`.profile`
feature of the Unix shells.
.. % XXX This should probably be dumped in an appendix, since most people
.. % don't use Python interactively in non-trivial ways.
.. XXX This should probably be dumped in an appendix, since most people
don't use Python interactively in non-trivial ways.
This file is only read in interactive sessions, not when Python reads commands
from a script, and not when :file:`/dev/tty` is given as the explicit source of

View file

@ -11,18 +11,11 @@ with a prompt are output from the interpreter. Note that a secondary prompt on a
line by itself in an example means you must type a blank line; this is used to
end a multi-line command.
.. %
.. % \footnote{
.. % I'd prefer to use different fonts to distinguish input
.. % from output, but the amount of LaTeX hacking that would require
.. % is currently beyond my ability.
.. % }
Many of the examples in this manual, even those entered at the interactive
prompt, include comments. Comments in Python start with the hash character,
``'#'``, and extend to the end of the physical line. A comment may appear at
``#``, and extend to the end of the physical line. A comment may appear at
the start of a line or following whitespace or code, but not within a string
literal. A hash character within a string literal is just a hash character.
literal. A hash character within a string literal is just a hash character.
Some examples::
@ -642,5 +635,3 @@ This example introduces several new features.
Note that the interpreter inserts a newline before it prints the next prompt if
the last line was not completed.

View file

@ -218,8 +218,6 @@ Some tips for experts:
* The module :mod:`compileall` can create :file:`.pyc` files (or :file:`.pyo`
files when :option:`-O` is used) for all modules in a directory.
.. %
.. _tut-standardmodules:
@ -238,11 +236,7 @@ depends on the underlying platform For example, the :mod:`winreg` module is only
provided on Windows systems. One particular module deserves some attention:
:mod:`sys`, which is built into every Python interpreter. The variables
``sys.ps1`` and ``sys.ps2`` define the strings used as primary and secondary
prompts:
.. %
::
prompts::
>>> import sys
>>> sys.ps1
@ -451,8 +445,6 @@ filename! On these platforms, there is no guaranteed way to know whether a file
file names with a capitalized first letter.) The DOS 8+3 filename restriction
adds another interesting problem for long module names.
.. % The \code{__all__} Attribute
The only solution is for the package author to provide an explicit index of the
package. The import statement uses the following convention: if a package's
:file:`__init__.py` code defines a list named ``__all__``, it is taken to be the

View file

@ -61,8 +61,8 @@ archives are available at http://mail.python.org/pipermail/. The FAQ answers
many of the questions that come up again and again, and may already contain the
solution for your problem.
.. % Postings figure based on average of last six months activity as
.. % reported by www.egroups.com; Jan. 2000 - June 2000: 21272 msgs / 182
.. % days = 116.9 msgs / day and steadily increasing.
.. Postings figure based on average of last six months activity as
reported by www.egroups.com; Jan. 2000 - June 2000: 21272 msgs / 182
days = 116.9 msgs / day and steadily increasing. (XXX up to date figures?)