Merged revisions 66457-66459,66465-66468,66483-66485,66487-66491 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r66457 | antoine.pitrou | 2008-09-13 15:30:30 -0500 (Sat, 13 Sep 2008) | 5 lines

  Issue #3850: Misc/find_recursionlimit.py was broken.

  Reviewed by A.M. Kuchling.
........
  r66458 | benjamin.peterson | 2008-09-13 17:54:43 -0500 (Sat, 13 Sep 2008) | 1 line

  fix a name issue; note all doc files should be encoded in utf8
........
  r66459 | benjamin.peterson | 2008-09-14 11:02:22 -0500 (Sun, 14 Sep 2008) | 1 line

  clarify that radix for int is not 'guessed'
........
  r66465 | skip.montanaro | 2008-09-14 21:03:05 -0500 (Sun, 14 Sep 2008) | 3 lines

  Review usage.  Fix a mistake in the new-style class definition.  Add a
  couple new definitions (CPython and virtual machine).
........
  r66466 | skip.montanaro | 2008-09-14 21:19:53 -0500 (Sun, 14 Sep 2008) | 2 lines

  Pick up a few more definitions from the glossary on the wiki.
........
  r66467 | benjamin.peterson | 2008-09-14 21:53:23 -0500 (Sun, 14 Sep 2008) | 1 line

  mention that object.__init__ no longer takes arbitrary args and kwargs
........
  r66468 | andrew.kuchling | 2008-09-15 08:08:32 -0500 (Mon, 15 Sep 2008) | 1 line

  Rewrite item a bit
........
  r66483 | georg.brandl | 2008-09-16 05:17:45 -0500 (Tue, 16 Sep 2008) | 2 lines

  Fix typo.
........
  r66484 | benjamin.peterson | 2008-09-16 16:20:28 -0500 (Tue, 16 Sep 2008) | 2 lines

  be less wordy
........
  r66485 | georg.brandl | 2008-09-17 03:45:54 -0500 (Wed, 17 Sep 2008) | 2 lines

  #3888: add some deprecated modules in whatsnew.
........
  r66487 | skip.montanaro | 2008-09-17 06:50:36 -0500 (Wed, 17 Sep 2008) | 2 lines

  usage
........
  r66488 | andrew.kuchling | 2008-09-17 07:57:04 -0500 (Wed, 17 Sep 2008) | 1 line

  Markup fixes
........
  r66489 | andrew.kuchling | 2008-09-17 07:58:22 -0500 (Wed, 17 Sep 2008) | 2 lines

  Remove comment about improvement: pystone is about the same, and
  the improvements seem to be difficult to quantify
........
  r66490 | andrew.kuchling | 2008-09-17 08:04:53 -0500 (Wed, 17 Sep 2008) | 1 line

  Note sqlite3 version; move item
........
  r66491 | benjamin.peterson | 2008-09-17 16:54:56 -0500 (Wed, 17 Sep 2008) | 1 line

  document compileall command flags
........
This commit is contained in:
Benjamin Peterson 2008-09-17 22:25:09 +00:00
parent 357877c8f1
commit 5478b47355
7 changed files with 216 additions and 113 deletions

View File

@ -9,16 +9,17 @@ Glossary
.. glossary:: .. glossary::
``>>>`` ``>>>``
The typical Python prompt of the interactive shell. Often seen for code The default Python prompt of the interactive shell. Often seen for code
examples that can be tried right away in the interpreter. examples which can be executed interactively in the interpreter.
``...`` ``...``
The typical Python prompt of the interactive shell when entering code for The default Python prompt of the interactive shell when entering code for
an indented code block. an indented code block or within a pair of matching left and right
delimiters (parentheses, square brackets or curly braces).
2to3 2to3
A tool that tries to convert Python 2.x code to Python 3.x code by A tool that tries to convert Python 2.x code to Python 3.x code by
handling most of the incompatibilites that can be detected by parsing the handling most of the incompatibilites which can be detected by parsing the
source and traversing the parse tree. source and traversing the parse tree.
2to3 is available in the standard library as :mod:`lib2to3`; a standalone 2to3 is available in the standard library as :mod:`lib2to3`; a standalone
@ -34,15 +35,21 @@ Glossary
ABC with the :mod:`abc` module. ABC with the :mod:`abc` module.
argument argument
A value passed to a function or method, assigned to a name local to A value passed to a function or method, assigned to a named local
the body. A function or method may have both positional arguments and variable in the function body. A function or method may have both
keyword arguments in its definition. Positional and keyword arguments positional arguments and keyword arguments in its definition.
may be variable-length: ``*`` accepts or passes (if in the function Positional and keyword arguments may be variable-length: ``*`` accepts
definition or call) several positional arguments in a list, while ``**`` or passes (if in the function definition or call) several positional
does the same for keyword arguments in a dictionary. arguments in a list, while ``**`` does the same for keyword arguments
in a dictionary.
Any expression may be used within the argument list, and the evaluated Any expression may be used within the argument list, and the evaluated
value is passed to the local variable. value is passed to the local variable.
attribute
A value associated with an object which is referenced by name using
dotted expressions. For example, if an object *o* has an attribute
*a* it would be referenced as *o.a*.
BDFL BDFL
Benevolent Dictator For Life, a.k.a. `Guido van Rossum Benevolent Dictator For Life, a.k.a. `Guido van Rossum
@ -53,8 +60,26 @@ Glossary
of a Python program in the interpreter. The bytecode is also cached in of a Python program in the interpreter. The bytecode is also cached in
``.pyc`` and ``.pyo`` files so that executing the same file is faster the ``.pyc`` and ``.pyo`` files so that executing the same file is faster the
second time (recompilation from source to bytecode can be avoided). This second time (recompilation from source to bytecode can be avoided). This
"intermediate language" is said to run on a "virtual machine" that calls "intermediate language" is said to run on a :term:`virtual machine`
the subroutines corresponding to each bytecode. that executes the machine code corresponding to each bytecode.
class
A template for creating user-defined objects. Class definitions
normally contain method definitions which operate on instances of the
class.
coercion
The implicit conversion of an instance of one type to another during an
operation which involves two arguments of the same type. For example,
``int(3.15)`` converts the floating point number to the integer ``3``, but
in ``3+4.5``, each argument is of a different type (one int, one float),
and both must be converted to the same type before they can be added or it
will raise a ``TypeError``. Coercion between two operands can be
performed with the ``coerce`` builtin function; thus, ``3+4.5`` is
equivalent to calling ``operator.add(*coerce(3, 4.5))`` and results in
``operator.add(3.0, 4.5)``. Without coercion, all arguments of even
compatible types would have to be normalized to the same value by the
programmer, e.g., ``float(3)+4.5`` rather than just ``3+4.5``.
complex number complex number
An extension of the familiar real number system in which all numbers are An extension of the familiar real number system in which all numbers are
@ -69,10 +94,15 @@ Glossary
it's almost certain you can safely ignore them. it's almost certain you can safely ignore them.
context manager context manager
An objects that controls the environment seen in a :keyword:`with` An object which controls the environment seen in a :keyword:`with`
statement by defining :meth:`__enter__` and :meth:`__exit__` methods. statement by defining :meth:`__enter__` and :meth:`__exit__` methods.
See :pep:`343`. See :pep:`343`.
CPython
The canonical implementation of the Python programming language. The
term "CPython" is used in contexts when necessary to distinguish this
implementation from others such as Jython or IronPython.
decorator decorator
A function returning another function, usually applied as a function A function returning another function, usually applied as a function
transformation using the ``@wrapper`` syntax. Common examples for transformation using the ``@wrapper`` syntax. Common examples for
@ -92,7 +122,7 @@ Glossary
The same concept exists for classes, but is less commonly used there. The same concept exists for classes, but is less commonly used there.
descriptor descriptor
An object that defines the methods :meth:`__get__`, :meth:`__set__`, or Any object which defines the methods :meth:`__get__`, :meth:`__set__`, or
:meth:`__delete__`. When a class attribute is a descriptor, its special :meth:`__delete__`. When a class attribute is a descriptor, its special
binding behavior is triggered upon attribute lookup. Normally, using binding behavior is triggered upon attribute lookup. Normally, using
*a.b* to get, set or delete an attribute looks up the object named *b* in *a.b* to get, set or delete an attribute looks up the object named *b* in
@ -106,20 +136,20 @@ Glossary
dictionary dictionary
An associative array, where arbitrary keys are mapped to values. The use An associative array, where arbitrary keys are mapped to values. The use
of :class:`dict` much resembles that for :class:`list`, but the keys can of :class:`dict` closely resembles that for :class:`list`, but the keys can
be any object with a :meth:`__hash__` function, not just integers starting be any object with a :meth:`__hash__` function, not just integers.
from zero. Called a hash in Perl. Called a hash in Perl.
docstring docstring
A docstring ("documentation string") is a string literal that appears as A string literal which appears as the first expression in a class,
the first thing in a class or function suite. While ignored when the function or module. While ignored when the suite is executed, it is
suite is executed, it is recognized by the compiler and put into the recognized by the compiler and put into the :attr:`__doc__` attribute
:attr:`__doc__` attribute of the class or function. Since it is available of the enclosing class, function or module. Since it is available via
via introspection, it is the canonical place for documentation of the introspection, it is the canonical place for documentation of the
object. object.
duck-typing duck-typing
Pythonic programming style that determines an object's type by inspection A pythonic programming style which determines an object's type by inspection
of its method or attribute signature rather than by explicit relationship of its method or attribute signature rather than by explicit relationship
to some type object ("If it looks like a duck and quacks like a duck, it to some type object ("If it looks like a duck and quacks like a duck, it
must be a duck.") By emphasizing interfaces rather than specific types, must be a duck.") By emphasizing interfaces rather than specific types,
@ -134,20 +164,20 @@ Glossary
style assumes the existence of valid keys or attributes and catches style assumes the existence of valid keys or attributes and catches
exceptions if the assumption proves false. This clean and fast style is exceptions if the assumption proves false. This clean and fast style is
characterized by the presence of many :keyword:`try` and :keyword:`except` characterized by the presence of many :keyword:`try` and :keyword:`except`
statements. The technique contrasts with the :term:`LBYL` style that is statements. The technique contrasts with the :term:`LBYL` style
common in many other languages such as C. common to many other languages such as C.
expression expression
A piece of syntax which can be evaluated to some value. In other words, A piece of syntax which can be evaluated to some value. In other words,
an expression is an accumulation of expression elements like literals, names, an expression is an accumulation of expression elements like literals,
attribute access, operators or function calls that all return a value. names, attribute access, operators or function calls which all return a
In contrast to other languages, not all language constructs are expressions, value. In contrast to many other languages, not all language constructs
but there are also :term:`statement`\s that cannot be used as expressions, are expressions. There are also :term:`statement`\s which cannot be used
such as :keyword:`while` or :keyword:`if`. Assignments are also not as expressions, such as :keyword:`if`. Assignments are also statements,
expressions. not expressions.
extension module extension module
A module written in C, using Python's C API to interact with the core and A module written in C or C++, using Python's C API to interact with the core and
with user code. with user code.
function function
@ -178,10 +208,10 @@ Glossary
collector that is able to detect and break reference cycles. collector that is able to detect and break reference cycles.
generator generator
A function that returns an iterator. It looks like a normal function A function which returns an iterator. It looks like a normal function
except that values are returned to the caller using a :keyword:`yield` except that values are returned to the caller using a :keyword:`yield`
statement instead of a :keyword:`return` statement. Generator functions statement instead of a :keyword:`return` statement. Generator functions
often contain one or more :keyword:`for` or :keyword:`while` loops that often contain one or more :keyword:`for` or :keyword:`while` loops which
:keyword:`yield` elements back to the caller. The function execution is :keyword:`yield` elements back to the caller. The function execution is
stopped at the :keyword:`yield` keyword (returning the result) and is stopped at the :keyword:`yield` keyword (returning the result) and is
resumed there when the next element is requested by calling the resumed there when the next element is requested by calling the
@ -202,39 +232,41 @@ Glossary
See :term:`global interpreter lock`. See :term:`global interpreter lock`.
global interpreter lock global interpreter lock
The lock used by Python threads to assure that only one thread can be run The lock used by Python threads to assure that only one thread
at a time. This simplifies Python by assuring that no two processes can executes in the :term:`CPython` :term:`virtual machine` at a time.
access the same memory at the same time. Locking the entire interpreter This simplifies the CPython implementation by assuring that no two
makes it easier for the interpreter to be multi-threaded, at the expense processes can access the same memory at the same time. Locking the
of some parallelism on multi-processor machines. Efforts have been made entire interpreter makes it easier for the interpreter to be
in the past to create a "free-threaded" interpreter (one which locks multi-threaded, at the expense of much of the parallelism afforded by
shared data at a much finer granularity), but performance suffered in the multi-processor machines. Efforts have been made in the past to
common single-processor case. create a "free-threaded" interpreter (one which locks shared data at a
much finer granularity), but so far none have been successful because
performance suffered in the common single-processor case.
hashable hashable
An object is *hashable* if it has a hash value that never changes during An object is *hashable* if it has a hash value which never changes during
its lifetime (it needs a :meth:`__hash__` method), and can be compared to its lifetime (it needs a :meth:`__hash__` method), and can be compared to
other objects (it needs an :meth:`__eq__` or :meth:`__cmp__` method). other objects (it needs an :meth:`__eq__` or :meth:`__cmp__` method).
Hashable objects that compare equal must have the same hash value. Hashable objects which compare equal must have the same hash value.
Hashability makes an object usable as a dictionary key and a set member, Hashability makes an object usable as a dictionary key and a set member,
because these data structures use the hash value internally. because these data structures use the hash value internally.
All of Python's immutable built-in objects are hashable, while all mutable All of Python's immutable built-in objects are hashable, while no mutable
containers (such as lists or dictionaries) are not. Objects that are containers (such as lists or dictionaries) are. Objects which are
instances of user-defined classes are hashable by default; they all instances of user-defined classes are hashable by default; they all
compare unequal, and their hash value is their :func:`id`. compare unequal, and their hash value is their :func:`id`.
IDLE IDLE
An Integrated Development Environment for Python. IDLE is a basic editor An Integrated Development Environment for Python. IDLE is a basic editor
and interpreter environment that ships with the standard distribution of and interpreter environment which ships with the standard distribution of
Python. Good for beginners, it also serves as clear example code for Python. Good for beginners, it also serves as clear example code for
those wanting to implement a moderately sophisticated, multi-platform GUI those wanting to implement a moderately sophisticated, multi-platform GUI
application. application.
immutable immutable
An object with fixed value. Immutable objects are numbers, strings or An object with a fixed value. Immutable objects include numbers, strings and
tuples (and more). Such an object cannot be altered. A new object has to tuples. Such an object cannot be altered. A new object has to
be created if a different value has to be stored. They play an important be created if a different value has to be stored. They play an important
role in places where a constant hash value is needed, for example as a key role in places where a constant hash value is needed, for example as a key
in a dictionary. in a dictionary.
@ -252,18 +284,21 @@ Glossary
:term:`__future__`. :term:`__future__`.
interactive interactive
Python has an interactive interpreter which means that you can try out Python has an interactive interpreter which means you can enter
things and immediately see their results. Just launch ``python`` with no statements and expressions at the interpreter prompt, immediately
arguments (possibly by selecting it from your computer's main menu). It is execute them and see their results. Just launch ``python`` with no
a very powerful way to test out new ideas or inspect modules and packages arguments (possibly by selecting it from your computer's main
(remember ``help(x)``). menu). It is a very powerful way to test out new ideas or inspect
modules and packages (remember ``help(x)``).
interpreted interpreted
Python is an interpreted language, as opposed to a compiled one. This Python is an interpreted language, as opposed to a compiled one,
means that the source files can be run directly without first creating an though the distinction can be blurry because of the presence of the
executable which is then run. Interpreted languages typically have a bytecode compiler. This means that source files can be run directly
shorter development/debug cycle than compiled ones, though their programs without explicitly creating an executable which is then run.
generally also run more slowly. See also :term:`interactive`. Interpreted languages typically have a shorter development/debug cycle
than compiled ones, though their programs generally also run more
slowly. See also :term:`interactive`.
iterable iterable
A container object capable of returning its members one at a A container object capable of returning its members one at a
@ -283,15 +318,15 @@ Glossary
iterator iterator
An object representing a stream of data. Repeated calls to the iterator's An object representing a stream of data. Repeated calls to the iterator's
:meth:`__next__` (or passing it to the builtin function) :func:`next` :meth:`__next__` (or passing it to the builtin function) :func:`next`
method return successive items in the stream. When no more data is method return successive items in the stream. When no more data are
available a :exc:`StopIteration` exception is raised instead. At this available a :exc:`StopIteration` exception is raised instead. At this
point, the iterator object is exhausted and any further calls to its point, the iterator object is exhausted and any further calls to its
:meth:`__next__` method just raise :exc:`StopIteration` again. Iterators :meth:`next` method just raise :exc:`StopIteration` again. Iterators are
are required to have an :meth:`__iter__` method that returns the iterator required to have an :meth:`__iter__` method that returns the iterator
object itself so every iterator is also iterable and may be used in most object itself so every iterator is also iterable and may be used in most
places where other iterables are accepted. One notable exception is code places where other iterables are accepted. One notable exception is code
that attempts multiple iteration passes. A container object (such as a which attempts multiple iteration passes. A container object (such as a
:class:`list`) produces a fresh new iterator each time you pass it to the :class:`list`) produces a fresh new iterator each time you pass it to the
:func:`iter` function or use it in a :keyword:`for` loop. Attempting this :func:`iter` function or use it in a :keyword:`for` loop. Attempting this
with an iterator will just return the same exhausted iterator object used with an iterator will just return the same exhausted iterator object used
@ -315,17 +350,22 @@ Glossary
pre-conditions before making calls or lookups. This style contrasts with pre-conditions before making calls or lookups. This style contrasts with
the :term:`EAFP` approach and is characterized by the presence of many the :term:`EAFP` approach and is characterized by the presence of many
:keyword:`if` statements. :keyword:`if` statements.
list
A built-in Python :term:`sequence`. Despite its name it is more akin
to an array in other languages than to a linked list since access to
elements are O(1).
list comprehension list comprehension
A compact way to process all or a subset of elements in a sequence and A compact way to process all or part of the elements in a sequence and
return a list with the results. ``result = ["0x%02x" % x for x in return a list with the results. ``result = ["0x%02x" % x for x in
range(256) if x % 2 == 0]`` generates a list of strings containing hex range(256) if x % 2 == 0]`` generates a list of strings containing
numbers (0x..) that are even and in the range from 0 to 255. The even hex numbers (0x..) in the range from 0 to 255. The :keyword:`if`
:keyword:`if` clause is optional. If omitted, all elements in clause is optional. If omitted, all elements in ``range(256)`` are
``range(256)`` are processed. processed.
mapping mapping
A container object (such as :class:`dict`) that supports arbitrary key A container object (such as :class:`dict`) which supports arbitrary key
lookups using the special method :meth:`__getitem__`. lookups using the special method :meth:`__getitem__`.
metaclass metaclass
@ -342,7 +382,7 @@ Glossary
More information can be found in :ref:`metaclasses`. More information can be found in :ref:`metaclasses`.
method method
A function that is defined inside a class body. If called as an attribute A function which is defined inside a class body. If called as an attribute
of an instance of that class, the method will get the instance object as of an instance of that class, the method will get the instance object as
its first :term:`argument` (which is usually called ``self``). its first :term:`argument` (which is usually called ``self``).
See :term:`function` and :term:`nested scope`. See :term:`function` and :term:`nested scope`.
@ -352,7 +392,7 @@ Glossary
also :term:`immutable`. also :term:`immutable`.
named tuple named tuple
Any tuple subclass whose indexable fields are also accessible with Any tuple subclass whose indexable elements are also accessible using
named attributes (for example, :func:`time.localtime` returns a named attributes (for example, :func:`time.localtime` returns a
tuple-like object where the *year* is accessible either with an tuple-like object where the *year* is accessible either with an
index such as ``t[0]`` or with a named attribute like ``t.tm_year``). index such as ``t[0]`` or with a named attribute like ``t.tm_year``).
@ -374,7 +414,7 @@ Glossary
it clear which module implements a function. For instance, writing it clear which module implements a function. For instance, writing
:func:`random.seed` or :func:`itertools.izip` makes it clear that those :func:`random.seed` or :func:`itertools.izip` makes it clear that those
functions are implemented by the :mod:`random` and :mod:`itertools` functions are implemented by the :mod:`random` and :mod:`itertools`
modules respectively. modules, respectively.
nested scope nested scope
The ability to refer to a variable in an enclosing definition. For The ability to refer to a variable in an enclosing definition. For
@ -390,6 +430,13 @@ Glossary
versatile features like :attr:`__slots__`, descriptors, properties, versatile features like :attr:`__slots__`, descriptors, properties,
:meth:`__getattribute__`, class methods, and static methods. :meth:`__getattribute__`, class methods, and static methods.
More information can be found in :ref:`newstyle`.
object
Any data with state (attributes or value) and defined behavior
(methods). Also the ultimate base class of any :term:`new-style
class`.
positional argument positional argument
The arguments assigned to local names inside a function or method, The arguments assigned to local names inside a function or method,
determined by the order in which they were given in the call. ``*`` is determined by the order in which they were given in the call. ``*`` is
@ -403,11 +450,12 @@ Glossary
abbreviated "Py3k". abbreviated "Py3k".
Pythonic Pythonic
An idea or piece of code which closely follows the most common idioms of An idea or piece of code which closely follows the most common idioms
the Python language, rather than implementing code using concepts common of the Python language, rather than implementing code using concepts
in other languages. For example, a common idiom in Python is the :keyword:`for` common to other languages. For example, a common idiom in Python is
loop structure; other languages don't have this easy keyword, so people to loop over all elements of an iterable using a :keyword:`for`
use a numerical counter instead:: statement. Many other languages don't have this type of construct, so
people unfamiliar with Python sometimes use a numerical counter instead::
for i in range(len(food)): for i in range(len(food)):
print(food[i]) print(food[i])
@ -418,11 +466,13 @@ Glossary
print(piece) print(piece)
reference count reference count
The number of places where a certain object is referenced to. When the The number of references to an object. When the reference count of an
reference count drops to zero, an object is deallocated. While reference object drops to zero, it is deallocated. Reference counting is
counting is invisible on the Python code level, it is used on the generally not visible to Python code, but it is a key element of the
implementation level to keep track of allocated memory. :term:`CPython` implementation. The :mod:`sys` module defines a
:func:`getrefcount` function that programmers can call to return the
reference count for a particular object.
__slots__ __slots__
A declaration inside a class that saves memory by pre-declaring space for A declaration inside a class that saves memory by pre-declaring space for
instance attributes and eliminating instance dictionaries. Though instance attributes and eliminating instance dictionaries. Though
@ -432,7 +482,8 @@ Glossary
sequence sequence
An :term:`iterable` which supports efficient element access using integer An :term:`iterable` which supports efficient element access using integer
indices via the :meth:`__getitem__` and :meth:`__len__` special methods. indices via the :meth:`__getitem__` special method and defines a
:meth:`len` method that returns the length of the sequence.
Some built-in sequence types are :class:`list`, :class:`str`, Some built-in sequence types are :class:`list`, :class:`str`,
:class:`tuple`, and :class:`unicode`. Note that :class:`dict` also :class:`tuple`, and :class:`unicode`. Note that :class:`dict` also
supports :meth:`__getitem__` and :meth:`__len__`, but is considered a supports :meth:`__getitem__` and :meth:`__len__`, but is considered a
@ -450,10 +501,23 @@ Glossary
an :term:`expression` or a one of several constructs with a keyword, such an :term:`expression` or a one of several constructs with a keyword, such
as :keyword:`if`, :keyword:`while` or :keyword:`for`. as :keyword:`if`, :keyword:`while` or :keyword:`for`.
triple-quoted string
A string which is bound by three instances of either a quotation mark
(") or an apostrophe ('). While they don't provide any functionality
not available with single-quoted strings, they are useful for a number
of reasons. They allow you to include unescaped single and double
quotes within a string and they can span multiple lines without the
use of the continuation character, making them especially useful when
writing docstrings.
type type
The type of a Python object determines what kind of object it is; every The type of a Python object determines what kind of object it is; every
object has a type. An object's type is accessible as its object has a type. An object's type is accessible as its
:attr:`__class__` attribute or can be retrieved with ``type(obj)``. :attr:`__class__` attribute or can be retrieved with ``type(obj)``.
virtual machine
A computer defined entirely in software. Python's virtual machine
executes the :term:`bytecode` emitted by the bytecode compiler.
Zen of Python Zen of Python
Listing of Python design principles and philosophies that are helpful in Listing of Python design principles and philosophies that are helpful in

View File

@ -79,12 +79,12 @@ flag. Note that *only* doctests will be refactored.
The :option:`-v` option enables the output of more information on the The :option:`-v` option enables the output of more information on the
translation process. translation process.
When the :option:`-p` is passed to it, 2to3 treats ``print`` as a function When the :option:`-p` is passed, 2to3 treats ``print`` as a function instead of
instead of a statement. This is useful when ``from __future__ import a statement. This is useful when ``from __future__ import print_function`` is
print_function`` is being used. If this option is not given, the print fixer being used. If this option is not given, the print fixer will surround print
will surround print calls in an extra set of parentheses because it cannot calls in an extra set of parentheses because it cannot differentiate between the
differentiate between the and print statement with parentheses (such as ``print and print statement with parentheses (such as ``print ("a" + "b" + "c")``) and a
("a" + "b" + "c")``) and a true function call. true function call.
:mod:`lib2to3` - 2to3's library :mod:`lib2to3` - 2to3's library

View File

@ -359,7 +359,7 @@ in Unix::
.. method:: defaultdict.__missing__(key) .. method:: defaultdict.__missing__(key)
If the :attr:`default_factory` attribute is ``None``, this raises an If the :attr:`default_factory` attribute is ``None``, this raises a
:exc:`KeyError` exception with the *key* as argument. :exc:`KeyError` exception with the *key* as argument.
If :attr:`default_factory` is not ``None``, it is called without arguments If :attr:`default_factory` is not ``None``, it is called without arguments

View File

@ -11,8 +11,13 @@ libraries. These functions compile Python source files in a directory tree,
allowing users without permission to write to the libraries to take advantage of allowing users without permission to write to the libraries to take advantage of
cached byte-code files. cached byte-code files.
The source file for this module may also be used as a script to compile Python This module may also be used as a script (using the :option:`-m` Python flag) to
sources in directories named on the command line or in ``sys.path``. compile Python sources. Directories to recursively traverse (passing
:option:`-l` stops the recursive behavior) for sources are listed on the command
line. If no arguments are given, the invocation is equivalent to ``-l
sys.path``. Printing lists of the files compiled can be disabled with the
:option:`-q` flag. In addition, the :option:`-x` option takes a regular
expression argument. All files that match the expression will be skipped.
.. function:: compile_dir(dir[, maxlevels[, ddir[, force[, rx[, quiet]]]]]) .. function:: compile_dir(dir[, maxlevels[, ddir[, force[, rx[, quiet]]]]])

View File

@ -368,7 +368,7 @@ complicated example::
As you can see, the :keyword:`finally` clause is executed in any event. The As you can see, the :keyword:`finally` clause is executed in any event. The
:exc:`TypeError` raised by dividing two strings is not handled by the :exc:`TypeError` raised by dividing two strings is not handled by the
:keyword:`except` clause and therefore re-raised after the :keyword:`finally` :keyword:`except` clause and therefore re-raised after the :keyword:`finally`
clauses has been executed. clause has been executed.
In real world applications, the :keyword:`finally` clause is useful for In real world applications, the :keyword:`finally` clause is useful for
releasing external resources (such as files or network connections), regardless releasing external resources (such as files or network connections), regardless

View File

@ -1723,9 +1723,6 @@ Optimizations
free lists when garbage-collecting the highest generation of objects. free lists when garbage-collecting the highest generation of objects.
This may return memory to the operating system sooner. This may return memory to the operating system sooner.
The net result of the 2.6 optimizations is that Python 2.6 runs the pystone
benchmark around XXX% faster than Python 2.5.
.. ====================================================================== .. ======================================================================
.. _new-26-interpreter: .. _new-26-interpreter:
@ -1794,7 +1791,6 @@ changes, or look through the Subversion logs for all the details.
:mod:`mimetools`, :mod:`mimetools`,
:mod:`multifile`, :mod:`multifile`,
:mod:`new`, :mod:`new`,
:mod:`popen2`,
:mod:`pure`, :mod:`pure`,
:mod:`statvfs`, :mod:`statvfs`,
:mod:`sunaudiodev`, :mod:`sunaudiodev`,
@ -1806,12 +1802,10 @@ changes, or look through the Subversion logs for all the details.
were applied. (Maintained by Josiah Carlson; see :issue:`1736190` for were applied. (Maintained by Josiah Carlson; see :issue:`1736190` for
one patch.) one patch.)
.. |uacute| unicode:: 0xA9 * The :mod:`bsddb` module also has a new maintainer, Jesús Cea, and the package
is now available as a standalone package. The web page for the package is
* The :mod:`bsddb` module also has a new maintainer, Jes|uacute|s Cea, `www.jcea.es/programacion/pybsddb.htm
and the package is now available as a standalone package. <http://www.jcea.es/programacion/pybsddb.htm>`__.
The web page for the package is
`www.jcea.es/programacion/pybsddb.htm <http://www.jcea.es/programacion/pybsddb.htm>`__.
* The :mod:`bsddb.dbshelve` module now uses the highest pickling protocol * The :mod:`bsddb.dbshelve` module now uses the highest pickling protocol
available, instead of restricting itself to protocol 1. available, instead of restricting itself to protocol 1.
@ -2134,6 +2128,13 @@ changes, or look through the Subversion logs for all the details.
(Contributed by Christian Heimes and Mark Dickinson.) (Contributed by Christian Heimes and Mark Dickinson.)
* The :mod:`MimeWriter` module and :mod:`mimify` module
have been deprecated; use the :mod:`email`
package instead.
* The :mod:`md5` module has been deprecated; use the :mod:`hashlib` module
instead.
* :class:`mmap` objects now have a :meth:`rfind` method that searches for a * :class:`mmap` objects now have a :meth:`rfind` method that searches for a
substring beginning at the end of the string and searching substring beginning at the end of the string and searching
backwards. The :meth:`find` method also gained an *end* parameter backwards. The :meth:`find` method also gained an *end* parameter
@ -2216,6 +2217,9 @@ changes, or look through the Subversion logs for all the details.
and can optionally take new command-line arguments for the program. and can optionally take new command-line arguments for the program.
(Contributed by Rocky Bernstein; :issue:`1393667`.) (Contributed by Rocky Bernstein; :issue:`1393667`.)
* The :mod:`posixfile` module has been deprecated; :func:`fcntl.lockf`
provides better locking.
The :func:`post_mortem` function, used to begin debugging a The :func:`post_mortem` function, used to begin debugging a
traceback, will now use the traceback returned by :func:`sys.exc_info` traceback, will now use the traceback returned by :func:`sys.exc_info`
if no traceback is supplied. (Contributed by Facundo Batista; if no traceback is supplied. (Contributed by Facundo Batista;
@ -2226,6 +2230,9 @@ changes, or look through the Subversion logs for all the details.
opcodes, returning a shorter pickle that contains the same data structure. opcodes, returning a shorter pickle that contains the same data structure.
(Contributed by Raymond Hettinger.) (Contributed by Raymond Hettinger.)
* The :mod:`popen2` module has been deprecated; use the :mod:`subprocess`
module.
* A :func:`get_data` function was added to the :mod:`pkgutil` * A :func:`get_data` function was added to the :mod:`pkgutil`
module that returns the contents of resource files included module that returns the contents of resource files included
with an installed Python package. For example:: with an installed Python package. For example::
@ -2305,6 +2312,9 @@ changes, or look through the Subversion logs for all the details.
* The :mod:`sets` module has been deprecated; it's better to * The :mod:`sets` module has been deprecated; it's better to
use the built-in :class:`set` and :class:`frozenset` types. use the built-in :class:`set` and :class:`frozenset` types.
* The :mod:`sha` module has been deprecated; use the :mod:`hashlib` module
instead.
* The :func:`shutil.copytree` function now has an optional *ignore* argument * The :func:`shutil.copytree` function now has an optional *ignore* argument
that takes a callable object. This callable will receive each directory path that takes a callable object. This callable will receive each directory path
and a list of the directory's contents, and returns a list of names that and a list of the directory's contents, and returns a list of names that
@ -2390,6 +2400,10 @@ changes, or look through the Subversion logs for all the details.
(Contributed by Pedro Werneck and Jeffrey Yasskin; (Contributed by Pedro Werneck and Jeffrey Yasskin;
:issue:`742598`, :issue:`1193577`.) :issue:`742598`, :issue:`1193577`.)
* The :mod:`sqlite3` module, maintained by Gerhard Haering,
has been updated from version 2.3.2 in Python 2.5 to
version 2.4.1.
* The :mod:`struct` module now supports the C99 :ctype:`_Bool` type, * The :mod:`struct` module now supports the C99 :ctype:`_Bool` type,
using the format character ``'?'``. using the format character ``'?'``.
(Contributed by David Remahl.) (Contributed by David Remahl.)
@ -3158,6 +3172,13 @@ that may require changes to your code:
before adding elements from the iterable. This change makes the before adding elements from the iterable. This change makes the
behavior match ``list.__init__()``. behavior match ``list.__init__()``.
* :meth:`object.__init__` previously accepted arbitrary arguments and
keyword arguments, ignoring them. In Python 2.6, this is no longer
allowed and will result in a :exc:`TypeError`. This will affect
:meth:`__init__` methods that end up calling the corresponding
method on :class:`object` (perhaps through using :func:`super`).
See :issue:`1683368` for discussion.
* The :class:`Decimal` constructor now accepts leading and trailing * The :class:`Decimal` constructor now accepts leading and trailing
whitespace when passed a string. Previously it would raise an whitespace when passed a string. Previously it would raise an
:exc:`InvalidOperation` exception. On the other hand, the :exc:`InvalidOperation` exception. On the other hand, the

View File

@ -1,22 +1,32 @@
#! /usr/bin/env python #! /usr/bin/env python
"""Find the maximum recursion limit that prevents core dumps """Find the maximum recursion limit that prevents interpreter termination.
This script finds the maximum safe recursion limit on a particular This script finds the maximum safe recursion limit on a particular
platform. If you need to change the recursion limit on your system, platform. If you need to change the recursion limit on your system,
this script will tell you a safe upper bound. To use the new limit, this script will tell you a safe upper bound. To use the new limit,
call sys.setrecursionlimit. call sys.setrecursionlimit().
This module implements several ways to create infinite recursion in This module implements several ways to create infinite recursion in
Python. Different implementations end up pushing different numbers of Python. Different implementations end up pushing different numbers of
C stack frames, depending on how many calls through Python's abstract C stack frames, depending on how many calls through Python's abstract
C API occur. C API occur.
After each round of tests, it prints a message After each round of tests, it prints a message:
Limit of NNNN is fine. "Limit of NNNN is fine".
It ends when Python causes a segmentation fault because the limit is The highest printed value of "NNNN" is therefore the highest potentially
too high. On platforms like Mac and Windows, it should exit with a safe limit for your system (which depends on the OS, architecture, but also
MemoryError. the compilation flags). Please note that it is practically impossible to
test all possible recursion paths in the interpreter, so the results of
this test should not be trusted blindly -- although they give a good hint
of which values are reasonable.
NOTE: When the C stack space allocated by your system is exceeded due
to excessive recursion, exact behaviour depends on the platform, although
the interpreter will always fail in a likely brutal way: either a
segmentation fault, a MemoryError, or just a silent abort.
NB: A program that does not use __methods__ can set a higher limit.
""" """
import sys import sys
@ -87,7 +97,10 @@ def check_limit(n, test_func_name):
test_func = globals()[test_func_name] test_func = globals()[test_func_name]
try: try:
test_func() test_func()
except RuntimeError: # AttributeError can be raised because of the way e.g. PyDict_GetItem()
# silences all exceptions and returns NULL, which is usually interpreted
# as "missing attribute".
except (RuntimeError, AttributeError):
pass pass
else: else:
print("Yikes!") print("Yikes!")