diff --git a/Demo/tkinter/guido/ss1.py b/Demo/tkinter/guido/ss1.py index 6a7aefcccaf..a6c8c2181ed 100644 --- a/Demo/tkinter/guido/ss1.py +++ b/Demo/tkinter/guido/ss1.py @@ -4,7 +4,6 @@ import os import re import sys import cgi -import rexec from xml.parsers import expat LEFT, CENTER, RIGHT = "LEFT", "CENTER", "RIGHT" @@ -33,16 +32,16 @@ class Sheet: def __init__(self): self.cells = {} # {(x, y): cell, ...} - self.rexec = rexec.RExec() - m = self.rexec.add_module('__main__') - m.cell = self.cellvalue - m.cells = self.multicellvalue - m.sum = sum + self.ns = dict( + cell = self.cellvalue, + cells = self.multicellvalue, + sum = sum, + ) def cellvalue(self, x, y): cell = self.getcell(x, y) if hasattr(cell, 'recalc'): - return cell.recalc(self.rexec) + return cell.recalc(self.ns) else: return cell @@ -144,7 +143,7 @@ class Sheet: self.reset() for cell in self.cells.values(): if hasattr(cell, 'recalc'): - cell.recalc(self.rexec) + cell.recalc(self.ns) def display(self): maxx, maxy = self.getsize() @@ -164,7 +163,7 @@ class Sheet: if x <= 0 or y <= 0: continue if hasattr(cell, 'recalc'): - cell.recalc(self.rexec) + cell.recalc(self.ns) if hasattr(cell, 'format'): text, alignment = cell.format() assert isinstance(text, str) @@ -317,7 +316,7 @@ class BaseCell: Subclasses may but needn't provide the following APIs: cell.reset() -- prepare for recalculation - cell.recalc(rexec) -> value -- recalculate formula + cell.recalc(ns) -> value -- recalculate formula cell.format() -> (value, alignment) -- return formatted value cell.xml() -> string -- return XML """ @@ -331,7 +330,7 @@ class NumericCell(BaseCell): self.fmt = fmt self.alignment = alignment - def recalc(self, rexec): + def recalc(self, ns): return self.value def format(self): @@ -372,7 +371,7 @@ class StringCell(BaseCell): self.fmt = fmt self.alignment = alignment - def recalc(self, rexec): + def recalc(self, ns): return self.text def format(self): @@ -398,13 +397,11 @@ class FormulaCell(BaseCell): def reset(self): self.value = None - def recalc(self, rexec): + def recalc(self, ns): if self.value is None: try: # A hack to evaluate expressions using true division - rexec.r_exec("from __future__ import division\n" + - "__value__ = eval(%s)" % repr(self.translated)) - self.value = rexec.r_eval("__value__") + self.value = eval(self.translated, ns) except: exc = sys.exc_info()[0] if hasattr(exc, "__name__"): diff --git a/Doc/conf.py b/Doc/conf.py index 9603b4b0e76..6a04a45c26e 100644 --- a/Doc/conf.py +++ b/Doc/conf.py @@ -128,7 +128,7 @@ latex_documents = [ ('tutorial/index', 'tutorial.tex', 'Python Tutorial', _stdauthor, 'manual'), ('using/index', 'using.tex', - 'Python Setup', _stdauthor, 'manual'), + 'Python Setup and Usage', _stdauthor, 'manual'), ('whatsnew/' + version, 'whatsnew.tex', 'What\'s New in Python', 'A. M. Kuchling', 'howto'), ] diff --git a/Doc/library/json.rst b/Doc/library/json.rst index e1f5cf2a17c..3b203a26dfc 100644 --- a/Doc/library/json.rst +++ b/Doc/library/json.rst @@ -82,12 +82,12 @@ Extending :class:`JSONEncoder`:: ... return [obj.real, obj.imag] ... return json.JSONEncoder.default(self, obj) ... - >>> dumps(2 + 1j, cls=ComplexEncoder) + >>> json.dumps(2 + 1j, cls=ComplexEncoder) '[2.0, 1.0]' >>> ComplexEncoder().encode(2 + 1j) '[2.0, 1.0]' >>> list(ComplexEncoder().iterencode(2 + 1j)) - ['[', '2.0', ', ', '1.0', ']'] + ['[2.0', ', 1.0', ']'] .. highlight:: none @@ -339,7 +339,7 @@ Encoders and decoders encoders and decoders. Otherwise, it will be a :exc:`ValueError` to encode such floats. - If *sort_keys* is ``True`` (the default), then the output of dictionaries + If *sort_keys* is ``True`` (default ``False``), then the output of dictionaries will be sorted by key; this is useful for regression tests to ensure that JSON serializations can be compared on a day-to-day basis. @@ -373,7 +373,7 @@ Encoders and decoders pass else: return list(iterable) - return JSONEncoder.default(self, o) + return json.JSONEncoder.default(self, o) .. method:: encode(o) @@ -381,7 +381,7 @@ Encoders and decoders Return a JSON string representation of a Python data structure, *o*. For example:: - >>> JSONEncoder().encode({"foo": ["bar", "baz"]}) + >>> json.JSONEncoder().encode({"foo": ["bar", "baz"]}) '{"foo": ["bar", "baz"]}' @@ -390,5 +390,5 @@ Encoders and decoders Encode the given object, *o*, and yield each string representation as available. For example:: - for chunk in JSONEncoder().iterencode(bigobject): + for chunk in json.JSONEncoder().iterencode(bigobject): mysocket.write(chunk) diff --git a/Doc/library/multiprocessing.rst b/Doc/library/multiprocessing.rst index bd79a3e76e1..27b4c907531 100644 --- a/Doc/library/multiprocessing.rst +++ b/Doc/library/multiprocessing.rst @@ -2210,8 +2210,8 @@ Synchronization types like locks, conditions and queues: .. literalinclude:: ../includes/mp_synchronize.py -An showing how to use queues to feed tasks to a collection of worker process and -collect the results: +An example showing how to use queues to feed tasks to a collection of worker +process and collect the results: .. literalinclude:: ../includes/mp_workers.py diff --git a/Doc/library/string.rst b/Doc/library/string.rst index dd04e3293fa..6748484cb99 100644 --- a/Doc/library/string.rst +++ b/Doc/library/string.rst @@ -299,11 +299,11 @@ The general form of a *standard format specifier* is: precision: `integer` type: "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%" -The *fill* character can be any character other than '}' (which signifies the -end of the field). The presence of a fill character is signaled by the *next* -character, which must be one of the alignment options. If the second character -of *format_spec* is not a valid alignment option, then it is assumed that both -the fill character and the alignment option are absent. +The *fill* character can be any character other than '{' or '}'. The presence +of a fill character is signaled by the character following it, which must be +one of the alignment options. If the second character of *format_spec* is not +a valid alignment option, then it is assumed that both the fill character and +the alignment option are absent. The meaning of the various alignment options is as follows: diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst index 3aaa6c6fa43..0c441f8c441 100644 --- a/Doc/library/subprocess.rst +++ b/Doc/library/subprocess.rst @@ -275,7 +275,7 @@ Exceptions Exceptions raised in the child process, before the new program has started to execute, will be re-raised in the parent. Additionally, the exception object will have one extra attribute called :attr:`child_traceback`, which is a string -containing traceback information from the childs point of view. +containing traceback information from the child's point of view. The most common exception raised is :exc:`OSError`. This occurs, for example, when trying to execute a non-existent file. Applications should prepare for diff --git a/Doc/library/threading.rst b/Doc/library/threading.rst index 68d0304fae9..2e36402006c 100644 --- a/Doc/library/threading.rst +++ b/Doc/library/threading.rst @@ -33,6 +33,8 @@ This module defines the following functions and objects: variable allows one or more threads to wait until they are notified by another thread. + See :ref:`condition-objects`. + .. function:: current_thread() @@ -58,6 +60,8 @@ This module defines the following functions and objects: with the :meth:`clear` method. The :meth:`wait` method blocks until the flag is true. + See :ref:`event-objects`. + .. class:: local @@ -80,6 +84,8 @@ This module defines the following functions and objects: acquired it, subsequent attempts to acquire it block, until it is released; any thread may release it. + See :ref:`lock-objects`. + .. function:: RLock() @@ -88,6 +94,8 @@ This module defines the following functions and objects: reentrant lock, the same thread may acquire it again without blocking; the thread must release it once for each time it has acquired it. + See :ref:`rlock-objects`. + .. function:: Semaphore(value=1) :noindex: @@ -98,6 +106,8 @@ This module defines the following functions and objects: if necessary until it can return without making the counter negative. If not given, *value* defaults to 1. + See :ref:`semaphore-objects`. + .. function:: BoundedSemaphore(value=1) @@ -109,15 +119,21 @@ This module defines the following functions and objects: .. class:: Thread + :noindex: A class that represents a thread of control. This class can be safely subclassed in a limited fashion. + See :ref:`thread-objects`. + .. class:: Timer + :noindex: A thread that executes a function after a specified interval has passed. + See :ref:`timer-objects`. + .. function:: settrace(func) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index e2db33cd2e4..5582cf65317 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -350,7 +350,8 @@ usage patterns to be encapsulated for convenient reuse. The execution of the :keyword:`with` statement with one "item" proceeds as follows: -#. The context expression is evaluated to obtain a context manager. +#. The context expression (the expression given in the :token:`with_item`) is + evaluated to obtain a context manager. #. The context manager's :meth:`__enter__` method is invoked. diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst index c71e89e694f..f6a90cc20e1 100644 --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -1297,6 +1297,7 @@ groups from right to left). | ``+``, ``-`` | Addition and subtraction | +-----------------------------------------------+-------------------------------------+ | ``*``, ``/``, ``//``, ``%`` | Multiplication, division, remainder | +| | [#]_ | +-----------------------------------------------+-------------------------------------+ | ``+x``, ``-x``, ``~x`` | Positive, negative, bitwise NOT | +-----------------------------------------------+-------------------------------------+ @@ -1339,5 +1340,7 @@ groups from right to left). the :keyword:`is` operator, like those involving comparisons between instance methods, or constants. Check their documentation for more info. +.. [#] The ``%`` is also used for string formatting; the same precedence applies. + .. [#] The power operator ``**`` binds less tightly than an arithmetic or bitwise unary operator on its right, that is, ``2**-1`` is ``0.5``. diff --git a/Doc/tools/sphinxext/indexcontent.html b/Doc/tools/sphinxext/indexcontent.html index e364dcefecf..10a070c6ab3 100644 --- a/Doc/tools/sphinxext/indexcontent.html +++ b/Doc/tools/sphinxext/indexcontent.html @@ -11,7 +11,7 @@ keep this under your pillow
Language Reference
describes syntax and language elements
Python Setup and Usage
how to use Python on different platforms
Python HOWTOs
in-depth documents on specific topics