Skip to content

Commit 91aaeac

Browse files
Issue #19193: Improved cross-references in the tutorial.
1 parent 7634e1c commit 91aaeac

File tree

2 files changed

+37
-33
lines changed

2 files changed

+37
-33
lines changed

Doc/tutorial/classes.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ will do nicely::
652652
A piece of Python code that expects a particular abstract data type can often be
653653
passed a class that emulates the methods of that data type instead. For
654654
instance, if you have a function that formats some data from a file object, you
655-
can define a class with methods :meth:`read` and :meth:`readline` that get the
655+
can define a class with methods :meth:`read` and :meth:`!readline` that get the
656656
data from a string buffer instead, and pass it as an argument.
657657

658658
.. (Unfortunately, this technique has its limitations: a class can't define
@@ -738,8 +738,8 @@ pervades and unifies Python. Behind the scenes, the :keyword:`for` statement
738738
calls :func:`iter` on the container object. The function returns an iterator
739739
object that defines the method :meth:`~iterator.__next__` which accesses
740740
elements in the container one at a time. When there are no more elements,
741-
:meth:`__next__` raises a :exc:`StopIteration` exception which tells the
742-
:keyword:`for` loop to terminate. You can call the :meth:`__next__` method
741+
:meth:`~iterator.__next__` raises a :exc:`StopIteration` exception which tells the
742+
:keyword:`for` loop to terminate. You can call the :meth:`~iterator.__next__` method
743743
using the :func:`next` built-in function; this example shows how it all works::
744744

745745
>>> s = 'abc'

Doc/tutorial/stdlib2.rst

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ formatting numbers with group separators::
7171
Templating
7272
==========
7373

74-
The :mod:`string` module includes a versatile :class:`Template` class with a
75-
simplified syntax suitable for editing by end-users. This allows users to
76-
customize their applications without having to alter the application.
74+
The :mod:`string` module includes a versatile :class:`~string.Template` class
75+
with a simplified syntax suitable for editing by end-users. This allows users
76+
to customize their applications without having to alter the application.
7777

7878
The format uses placeholder names formed by ``$`` with valid Python identifiers
7979
(alphanumeric characters and underscores). Surrounding the placeholder with
@@ -85,11 +85,11 @@ spaces. Writing ``$$`` creates a single escaped ``$``::
8585
>>> t.substitute(village='Nottingham', cause='the ditch fund')
8686
'Nottinghamfolk send $10 to the ditch fund.'
8787

88-
The :meth:`substitute` method raises a :exc:`KeyError` when a placeholder is not
89-
supplied in a dictionary or a keyword argument. For mail-merge style
90-
applications, user supplied data may be incomplete and the
91-
:meth:`safe_substitute` method may be more appropriate --- it will leave
92-
placeholders unchanged if data is missing::
88+
The :meth:`~string.Template.substitute` method raises a :exc:`KeyError` when a
89+
placeholder is not supplied in a dictionary or a keyword argument. For
90+
mail-merge style applications, user supplied data may be incomplete and the
91+
:meth:`~string.Template.safe_substitute` method may be more appropriate ---
92+
it will leave placeholders unchanged if data is missing::
9393

9494
>>> t = Template('Return the $item to $owner.')
9595
>>> d = dict(item='unladen swallow')
@@ -132,8 +132,9 @@ templates for XML files, plain text reports, and HTML web reports.
132132
Working with Binary Data Record Layouts
133133
=======================================
134134

135-
The :mod:`struct` module provides :func:`pack` and :func:`unpack` functions for
136-
working with variable length binary record formats. The following example shows
135+
The :mod:`struct` module provides :func:`~struct.pack` and
136+
:func:`~struct.unpack` functions for working with variable length binary
137+
record formats. The following example shows
137138
how to loop through header information in a ZIP file without using the
138139
:mod:`zipfile` module. Pack codes ``"H"`` and ``"I"`` represent two and four
139140
byte unsigned numbers respectively. The ``"<"`` indicates that they are
@@ -201,7 +202,7 @@ While those tools are powerful, minor design errors can result in problems that
201202
are difficult to reproduce. So, the preferred approach to task coordination is
202203
to concentrate all access to a resource in a single thread and then use the
203204
:mod:`queue` module to feed that thread with requests from other threads.
204-
Applications using :class:`Queue` objects for inter-thread communication and
205+
Applications using :class:`~queue.Queue` objects for inter-thread communication and
205206
coordination are easier to design, more readable, and more reliable.
206207

207208

@@ -231,8 +232,9 @@ This produces the following output:
231232
By default, informational and debugging messages are suppressed and the output
232233
is sent to standard error. Other output options include routing messages
233234
through email, datagrams, sockets, or to an HTTP Server. New filters can select
234-
different routing based on message priority: :const:`DEBUG`, :const:`INFO`,
235-
:const:`WARNING`, :const:`ERROR`, and :const:`CRITICAL`.
235+
different routing based on message priority: :const:`~logging.DEBUG`,
236+
:const:`~logging.INFO`, :const:`~logging.WARNING`, :const:`~logging.ERROR`,
237+
and :const:`~logging.CRITICAL`.
236238

237239
The logging system can be configured directly from Python or can be loaded from
238240
a user editable configuration file for customized logging without altering the
@@ -289,11 +291,11 @@ Many data structure needs can be met with the built-in list type. However,
289291
sometimes there is a need for alternative implementations with different
290292
performance trade-offs.
291293

292-
The :mod:`array` module provides an :class:`array()` object that is like a list
293-
that stores only homogeneous data and stores it more compactly. The following
294-
example shows an array of numbers stored as two byte unsigned binary numbers
295-
(typecode ``"H"``) rather than the usual 16 bytes per entry for regular lists of
296-
Python int objects::
294+
The :mod:`array` module provides an :class:`~array.array()` object that is like
295+
a list that stores only homogeneous data and stores it more compactly. The
296+
following example shows an array of numbers stored as two byte unsigned binary
297+
numbers (typecode ``"H"``) rather than the usual 16 bytes per entry for regular
298+
lists of Python int objects::
297299

298300
>>> from array import array
299301
>>> a = array('H', [4000, 10, 700, 22222])
@@ -302,10 +304,10 @@ Python int objects::
302304
>>> a[1:3]
303305
array('H', [10, 700])
304306

305-
The :mod:`collections` module provides a :class:`deque()` object that is like a
306-
list with faster appends and pops from the left side but slower lookups in the
307-
middle. These objects are well suited for implementing queues and breadth first
308-
tree searches::
307+
The :mod:`collections` module provides a :class:`~collections.deque()` object
308+
that is like a list with faster appends and pops from the left side but slower
309+
lookups in the middle. These objects are well suited for implementing queues
310+
and breadth first tree searches::
309311

310312
>>> from collections import deque
311313
>>> d = deque(["task1", "task2", "task3"])
@@ -351,8 +353,8 @@ not want to run a full list sort::
351353
Decimal Floating Point Arithmetic
352354
=================================
353355

354-
The :mod:`decimal` module offers a :class:`Decimal` datatype for decimal
355-
floating point arithmetic. Compared to the built-in :class:`float`
356+
The :mod:`decimal` module offers a :class:`~decimal.Decimal` datatype for
357+
decimal floating point arithmetic. Compared to the built-in :class:`float`
356358
implementation of binary floating point, the class is especially helpful for
357359

358360
* financial applications and other uses which require exact decimal
@@ -373,13 +375,15 @@ becomes significant if the results are rounded to the nearest cent::
373375
>>> round(.70 * 1.05, 2)
374376
0.73
375377

376-
The :class:`Decimal` result keeps a trailing zero, automatically inferring four
377-
place significance from multiplicands with two place significance. Decimal
378-
reproduces mathematics as done by hand and avoids issues that can arise when
379-
binary floating point cannot exactly represent decimal quantities.
378+
The :class:`~decimal.Decimal` result keeps a trailing zero, automatically
379+
inferring four place significance from multiplicands with two place
380+
significance. Decimal reproduces mathematics as done by hand and avoids
381+
issues that can arise when binary floating point cannot exactly represent
382+
decimal quantities.
380383

381-
Exact representation enables the :class:`Decimal` class to perform modulo
382-
calculations and equality tests that are unsuitable for binary floating point::
384+
Exact representation enables the :class:`~decimal.Decimal` class to perform
385+
modulo calculations and equality tests that are unsuitable for binary floating
386+
point::
383387

384388
>>> Decimal('1.00') % Decimal('.10')
385389
Decimal('0.00')

0 commit comments

Comments
 (0)