Merged revisions 61672,61674,61676-61678,61681,61683-61684 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r61672 | brett.cannon | 2008-03-20 17:13:48 +0100 (Do, 20 Mär 2008) | 2 lines Gave Jerry Seutter svn access for general Python development. ........ r61674 | marc-andre.lemburg | 2008-03-20 18:31:36 +0100 (Do, 20 Mär 2008) | 7 lines If Mark Hammonds win32 tools are not available, try to use the _winreg module and sys.getwindowsversion() to get at the Windows version info. For the machine and processor uname() values, use the environment variables for these on Windows XP and later. ........ r61676 | marc-andre.lemburg | 2008-03-20 18:55:31 +0100 (Do, 20 Mär 2008) | 5 lines Add documentation for updated Windows support in win32_ver(). Add documentation for linux_distribution() API. ........ r61677 | marc-andre.lemburg | 2008-03-20 19:08:00 +0100 (Do, 20 Mär 2008) | 2 lines Add news items for platform module changes. ........ r61678 | marc-andre.lemburg | 2008-03-20 19:58:14 +0100 (Do, 20 Mär 2008) | 3 lines Clarfiy the availability of the extended support for win32_ver() in Py2.6. ........ r61681 | andrew.kuchling | 2008-03-20 23:49:26 +0100 (Do, 20 Mär 2008) | 1 line Add lots of items ........ r61683 | eric.smith | 2008-03-21 00:04:04 +0100 (Fr, 21 Mär 2008) | 1 line Fixed PEP name. ........ r61684 | eric.smith | 2008-03-21 00:56:08 +0100 (Fr, 21 Mär 2008) | 1 line Comment how 'from __future__ import print_function' operates in 3.0. ........
This commit is contained in:
parent
3fd139951c
commit
02781dc754
|
@ -187,8 +187,10 @@ Windows Platform
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
This function only works if Mark Hammond's :mod:`win32all` package is installed
|
Note: this function works best with Mark Hammond's
|
||||||
and (obviously) only runs on Win32 compatible platforms.
|
:mod:`win32all` package installed, but also on Python 2.3 and
|
||||||
|
later (support for this was added in Python 2.6). It obviously
|
||||||
|
only runs on Win32 compatible platforms.
|
||||||
|
|
||||||
|
|
||||||
Win95/98 specific
|
Win95/98 specific
|
||||||
|
@ -222,13 +224,31 @@ Unix Platforms
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
|
||||||
.. function:: dist(distname='', version='', id='', supported_dists=('SuSE','debian','redhat','mandrake'))
|
.. function:: dist(distname='', version='', id='', supported_dists=('SuSE','debian','redhat','mandrake',...))
|
||||||
|
|
||||||
Tries to determine the name of the OS distribution name Returns a tuple
|
Tries to determine the name of the OS distribution name Returns a tuple
|
||||||
``(distname, version, id)`` which defaults to the args given as parameters.
|
``(distname, version, id)`` which defaults to the args given as parameters.
|
||||||
|
|
||||||
.. XXX Document linux_distribution()?
|
``supported_dists`` may be given to define the set of Linux
|
||||||
|
distributions to look for. It defaults to a list of currently
|
||||||
|
supported Linux distributions identified by their release file
|
||||||
|
name.
|
||||||
|
|
||||||
|
.. function:: linux_distribution(distname='', version='', id='', supported_dists=('SuSE','debian','redhat','mandrake',...), full_distribution_name=1)
|
||||||
|
|
||||||
|
Tries to determine the name of the Linux OS distribution name.
|
||||||
|
|
||||||
|
``supported_dists`` may be given to define the set of Linux
|
||||||
|
distributions to look for. It defaults to a list of currently
|
||||||
|
supported Linux distributions identified by their release file
|
||||||
|
name.
|
||||||
|
|
||||||
|
If ``full_distribution_name`` is true (default), the full
|
||||||
|
distribution read from the OS is returned. Otherwise the short name
|
||||||
|
taken from ``supported_dists`` is used.
|
||||||
|
|
||||||
|
Returns a tuple ``(distname,version,id)`` which defaults to the
|
||||||
|
args given as parameters.
|
||||||
|
|
||||||
.. function:: libc_ver(executable=sys.executable, lib='', version='', chunksize=2048)
|
.. function:: libc_ver(executable=sys.executable, lib='', version='', chunksize=2048)
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
What's New in Python 2.6
|
What's New in Python 2.6
|
||||||
****************************
|
****************************
|
||||||
|
|
||||||
.. XXX mention switch to Roundup for bug tracking
|
.. XXX add trademark info for Apple, Microsoft, SourceForge.
|
||||||
.. XXX add trademark info for Apple, Microsoft.
|
|
||||||
|
|
||||||
:Author: A.M. Kuchling
|
:Author: A.M. Kuchling
|
||||||
:Release: |release|
|
:Release: |release|
|
||||||
|
@ -43,12 +42,12 @@
|
||||||
|
|
||||||
* It's helpful to add the bug/patch number as a comment:
|
* It's helpful to add the bug/patch number as a comment:
|
||||||
|
|
||||||
% Patch 12345
|
.. Patch 12345
|
||||||
XXX Describe the transmogrify() function added to the socket
|
XXX Describe the transmogrify() function added to the socket
|
||||||
module.
|
module.
|
||||||
(Contributed by P.Y. Developer.)
|
(Contributed by P.Y. Developer.)
|
||||||
|
|
||||||
This saves the maintainer the effort of going through the SVN log
|
This saves the maintainer the effort of going through the SVN logs
|
||||||
when researching a change.
|
when researching a change.
|
||||||
|
|
||||||
This article explains the new features in Python 2.6. No release date for
|
This article explains the new features in Python 2.6. No release date for
|
||||||
|
@ -97,6 +96,14 @@ code to 3.0. The value of this switch is available
|
||||||
to Python code as the boolean variable ``sys.py3kwarning``,
|
to Python code as the boolean variable ``sys.py3kwarning``,
|
||||||
and to C extension code as :cdata:`Py_Py3kWarningFlag`.
|
and to C extension code as :cdata:`Py_Py3kWarningFlag`.
|
||||||
|
|
||||||
|
Python 3.0 adds several new built-in functions and change the
|
||||||
|
semantics of some existing built-ins. Entirely new functions such as
|
||||||
|
:func:`bin` have simply been added to Python 2.6, but existing
|
||||||
|
built-ins haven't been changed; instead, the :mod:`future_builtins`
|
||||||
|
module has versions with the new 3.0 semantics. Code written to be
|
||||||
|
compatible with 3.0 can do ``from future_builtins import hex, map``
|
||||||
|
as necessary.
|
||||||
|
|
||||||
.. seealso::
|
.. seealso::
|
||||||
|
|
||||||
The 3xxx series of PEPs, which describes the development process for
|
The 3xxx series of PEPs, which describes the development process for
|
||||||
|
@ -117,27 +124,57 @@ LaTeX to reStructured Text.
|
||||||
New Issue Tracker: Roundup
|
New Issue Tracker: Roundup
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
|
||||||
XXX write this -- this section is currently just brief notes.
|
For a long time, the Python developers have been growing increasingly
|
||||||
|
annoyed by SourceForge's bug tracker. SourceForge's hosted solution
|
||||||
|
doesn't permit much customization; for example, it wasn't possible to
|
||||||
|
customize the life cycle of issues.
|
||||||
|
|
||||||
The developers were growing increasingly annoyed by SourceForge's
|
The infrastructure committee of the Python Software Foundation
|
||||||
bug tracker. (Discuss problems in a sentence or two.)
|
therefore posted a call for issue trackers, asking volunteers to set
|
||||||
|
up different products and import some of the bugs and patches from
|
||||||
|
SourceForge. Four different trackers were examined: Atlassian's `Jira
|
||||||
|
<XXX>`__, `Launchpad <http://www.launchpad.net>`__, ` `Roundup
|
||||||
|
<XXX>`__, and Trac <XXX>`__. The committee eventually settled on Jira
|
||||||
|
and Roundup as the two candidates. Jira is a commercial product that
|
||||||
|
offers a no-cost hosted instance to free-software projects; Roundup
|
||||||
|
is an open-source project that requires volunteers
|
||||||
|
to administer it and a server to host it.
|
||||||
|
|
||||||
|
After posting a call for volunteers, a new Roundup installation was
|
||||||
|
set up at http://bugs.python.org. One installation of Roundup can
|
||||||
|
host multiple trackers, and this server now also hosts issue trackers
|
||||||
|
for Jython and for the Python web site. It will surely find
|
||||||
|
other uses in the future.
|
||||||
|
|
||||||
|
Hosting is kindly provided by `Upfront <XXX>`__ of XXX. Martin von
|
||||||
|
Loewis put a lot of effort into importing existing bugs and patches
|
||||||
|
from SourceForge; his scripts for this import are at XXX.
|
||||||
|
|
||||||
|
.. seealso::
|
||||||
|
|
||||||
|
XXX Roundup web site.
|
||||||
|
|
||||||
|
bugs.python.org
|
||||||
|
|
||||||
|
bugs.jython.org
|
||||||
|
|
||||||
|
Python web site bug tracker
|
||||||
|
|
||||||
Hosting provided by XXX.
|
|
||||||
|
|
||||||
New Documentation Format: ReStructured Text
|
New Documentation Format: ReStructured Text
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
|
||||||
Python's documentation had been written using LaTeX since the
|
Since the Python project's inception around 1989, the documentation
|
||||||
project's inception around 1989. At that time, most documentation was
|
had been written using LaTeX. At that time, most documentation was
|
||||||
printed out for later study, not viewed online. LaTeX was widely used
|
printed out for later study, not viewed online. LaTeX was widely used
|
||||||
because it provided attractive printed output while
|
because it provided attractive printed output while remaining
|
||||||
remaining straightforward to write, once the basic rules
|
straightforward to write, once the basic rules of the markup have been
|
||||||
of the markup have been learned.
|
learned.
|
||||||
|
|
||||||
LaTeX is still used today for writing technical publications destined
|
LaTeX is still used today for writing technical publications destined
|
||||||
for printing, but the landscape for programming tools has shifted. We
|
for printing, but the landscape for programming tools has shifted. We
|
||||||
no longer print out reams of documentation; instead, we browse through
|
no longer print out reams of documentation; instead, we browse through
|
||||||
it online and HTML is the most important format to support.
|
it online and HTML has become the most important format to support.
|
||||||
Unfortunately, converting LaTeX to HTML is fairly complicated, and
|
Unfortunately, converting LaTeX to HTML is fairly complicated, and
|
||||||
Fred L. Drake Jr., the Python documentation editor for many years,
|
Fred L. Drake Jr., the Python documentation editor for many years,
|
||||||
spent a lot of time wrestling the conversion process into shape.
|
spent a lot of time wrestling the conversion process into shape.
|
||||||
|
@ -459,26 +496,84 @@ can now be used in scripts running from inside a package.
|
||||||
PEP 3101: Advanced String Formatting
|
PEP 3101: Advanced String Formatting
|
||||||
=====================================================
|
=====================================================
|
||||||
|
|
||||||
XXX write this -- this section is currently just brief notes.
|
In Python 3.0, the `%` operator is supplemented by a more powerful
|
||||||
|
string formatting method, :meth:`format`. Support for the
|
||||||
|
:meth:`format` method has been backported to Python 2.6.
|
||||||
|
|
||||||
8-bit and Unicode strings have a .format() method that takes the arguments
|
In 2.6, both 8-bit and Unicode strings have a `.format()` method that
|
||||||
to be formatted.
|
treats the string as a template and takes the arguments to be formatted.
|
||||||
|
The formatting template uses curly brackets (`{`, `}`) as special characters::
|
||||||
|
|
||||||
.format() uses curly brackets ({, }) as special characters:
|
# Substitute positional argument 0 into the string.
|
||||||
|
"User ID: {0}".format("root") -> "User ID: root"
|
||||||
|
|
||||||
|
# Use the named keyword arguments
|
||||||
|
uid = 'root'
|
||||||
|
|
||||||
|
'User ID: {uid} Last seen: {last_login}'.format(uid='root',
|
||||||
|
last_login = '5 Mar 2008 07:20') ->
|
||||||
|
'User ID: root Last seen: 5 Mar 2008 07:20'
|
||||||
|
|
||||||
|
Curly brackets can be escaped by doubling them::
|
||||||
|
|
||||||
format("User ID: {0}", "root") -> "User ID: root"
|
|
||||||
format("Empty dict: {{}}") -> "Empty dict: {}"
|
format("Empty dict: {{}}") -> "Empty dict: {}"
|
||||||
0.name
|
|
||||||
0[name]
|
|
||||||
|
|
||||||
Format specifiers:
|
Field names can be integers indicating positional arguments, such as
|
||||||
|
``{0}``, ``{1}``, etc. or names of keyword arguments. You can also
|
||||||
|
supply compound field names that read attributes or access dictionary keys::
|
||||||
|
|
||||||
0:8 -> left-align, pad
|
import sys
|
||||||
0:>8 -> right-align, pad
|
'Platform: {0.platform}\nPython version: {0.version}'.format(sys) ->
|
||||||
|
'Platform: darwin\n
|
||||||
|
Python version: 2.6a1+ (trunk:61261M, Mar 5 2008, 20:29:41) \n
|
||||||
|
[GCC 4.0.1 (Apple Computer, Inc. build 5367)]'
|
||||||
|
|
||||||
|
import mimetypes
|
||||||
|
'Content-type: {0[.mp4]}'.format(mimetypes.types_map) ->
|
||||||
|
'Content-type: video/mp4'
|
||||||
|
|
||||||
|
Note that when using dictionary-style notation such as ``[.mp4]``, you
|
||||||
|
don't need to put any quotation marks around the string; it will look
|
||||||
|
up the value using ``.mp4`` as the key. Strings beginning with a
|
||||||
|
number will be converted to an integer. You can't write more
|
||||||
|
complicated expressions inside a format string.
|
||||||
|
|
||||||
|
So far we've shown how to specify which field to substitute into the
|
||||||
|
resulting string. The precise formatting used is also controllable by
|
||||||
|
adding a colon followed by a format specifier. For example:
|
||||||
|
|
||||||
|
# Field 0: left justify, pad to 15 characters
|
||||||
|
# Field 1: right justify, pad to 6 characters
|
||||||
|
fmt = '{0:15} ${1:>6}'
|
||||||
|
fmt.format('Registration', 35) ->
|
||||||
|
'Registration $ 35'
|
||||||
|
fmt.format('Tutorial', 50) ->
|
||||||
|
'Tutorial $ 50'
|
||||||
|
fmt.format('Banquet', 125) ->
|
||||||
|
'Banquet $ 125'
|
||||||
|
|
||||||
|
Format specifiers can reference other fields through nesting:
|
||||||
|
|
||||||
|
fmt = '{0:{1}}'
|
||||||
|
fmt.format('Invoice #1234', width) ->
|
||||||
|
'Invoice #1234 '
|
||||||
|
fmt.format('Invoice #1234', 15) ->
|
||||||
|
'Invoice #1234 '
|
||||||
|
|
||||||
|
The alignment of a field within the desired width can be specified:
|
||||||
|
|
||||||
|
================ ============================================
|
||||||
|
Character Effect
|
||||||
|
================ ============================================
|
||||||
|
< (default) Left-align
|
||||||
|
> Right-align
|
||||||
|
^ Center
|
||||||
|
= (For numeric types only) Pad after the sign.
|
||||||
|
================ ============================================
|
||||||
|
|
||||||
Format data types::
|
Format data types::
|
||||||
|
|
||||||
... take table from PEP 3101
|
... XXX take table from PEP 3101
|
||||||
|
|
||||||
Classes and types can define a __format__ method to control how it's
|
Classes and types can define a __format__ method to control how it's
|
||||||
formatted. It receives a single argument, the format specifier::
|
formatted. It receives a single argument, the format specifier::
|
||||||
|
@ -502,6 +597,42 @@ the type's :meth:`__format__` method with the provided specifier::
|
||||||
|
|
||||||
.. ======================================================================
|
.. ======================================================================
|
||||||
|
|
||||||
|
.. _pep-3105:
|
||||||
|
|
||||||
|
PEP 3105: ``print`` As a Function
|
||||||
|
=====================================================
|
||||||
|
|
||||||
|
The ``print`` statement becomes the :func:`print` function in Python 3.0.
|
||||||
|
Making :func:`print` a function makes it easier to replace within a
|
||||||
|
module by doing 'def print(...)' or importing a new
|
||||||
|
function from somewhere else.
|
||||||
|
|
||||||
|
Python 2.6 has a ``__future__`` import that removes ``print`` as language
|
||||||
|
syntax, letting you use the functional form instead. For example::
|
||||||
|
|
||||||
|
XXX need to check
|
||||||
|
from __future__ import print_function
|
||||||
|
print('# of entries', len(dictionary), file=sys.stderr)
|
||||||
|
|
||||||
|
The signature of the new function is::
|
||||||
|
|
||||||
|
def print(*args, sep=' ', end='\n', file=None)
|
||||||
|
|
||||||
|
The parameters are:
|
||||||
|
|
||||||
|
* **args**: positional arguments whose values will be printed out.
|
||||||
|
* **sep**: the separator, which will be printed between arguments.
|
||||||
|
* **end**: the ending text, which will be printed after all of the
|
||||||
|
arguments have been output.
|
||||||
|
* **file**: the file object to which the output will be sent.
|
||||||
|
|
||||||
|
.. seealso::
|
||||||
|
|
||||||
|
:pep:`3105` - Make print a function
|
||||||
|
PEP written by Georg Brandl.
|
||||||
|
|
||||||
|
.. ======================================================================
|
||||||
|
|
||||||
.. _pep-3110:
|
.. _pep-3110:
|
||||||
|
|
||||||
PEP 3110: Exception-Handling Changes
|
PEP 3110: Exception-Handling Changes
|
||||||
|
@ -643,24 +774,21 @@ New bin() built-in returns the binary form of a number.
|
||||||
PEP 3129: Class Decorators
|
PEP 3129: Class Decorators
|
||||||
=====================================================
|
=====================================================
|
||||||
|
|
||||||
XXX write this -- this section is currently just brief notes.
|
Decorators have been extended from functions to classes. It's now legal to
|
||||||
|
write::
|
||||||
|
|
||||||
Class decorators are analogous to function decorators. After defining a class,
|
|
||||||
it's passed through the specified series of decorator functions
|
|
||||||
and the ultimate return value is recorded as the class.
|
|
||||||
|
|
||||||
::
|
|
||||||
|
|
||||||
class A:
|
|
||||||
pass
|
|
||||||
A = foo(bar(A))
|
|
||||||
|
|
||||||
|
|
||||||
@foo
|
@foo
|
||||||
@bar
|
@bar
|
||||||
class A:
|
class A:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
This is equivalent to::
|
||||||
|
|
||||||
|
class A:
|
||||||
|
pass
|
||||||
|
|
||||||
|
A = foo(bar(A))
|
||||||
|
|
||||||
XXX need to find a good motivating example.
|
XXX need to find a good motivating example.
|
||||||
|
|
||||||
.. seealso::
|
.. seealso::
|
||||||
|
@ -911,6 +1039,11 @@ Here are all of the changes that Python 2.6 makes to the core Python language.
|
||||||
|
|
||||||
.. Patch 1591665
|
.. Patch 1591665
|
||||||
|
|
||||||
|
* Instance method objects have new attributes for the object and function
|
||||||
|
comprising the method; the new synonym for :attr:`im_self` is
|
||||||
|
:attr:`__self__`, and :attr:`im_func` is also available as :attr:`__func__`.
|
||||||
|
The old names are still supported in Python 2.6; they're gone in 3.0.
|
||||||
|
|
||||||
* An obscure change: when you use the the :func:`locals` function inside a
|
* An obscure change: when you use the the :func:`locals` function inside a
|
||||||
:keyword:`class` statement, the resulting dictionary no longer returns free
|
:keyword:`class` statement, the resulting dictionary no longer returns free
|
||||||
variables. (Free variables, in this case, are variables referred to in the
|
variables. (Free variables, in this case, are variables referred to in the
|
||||||
|
@ -945,7 +1078,11 @@ Optimizations
|
||||||
* Unicode strings now uses faster code for detecting
|
* Unicode strings now uses faster code for detecting
|
||||||
whitespace and line breaks; this speeds up the :meth:`split` method
|
whitespace and line breaks; this speeds up the :meth:`split` method
|
||||||
by about 25% and :meth:`splitlines` by 35%.
|
by about 25% and :meth:`splitlines` by 35%.
|
||||||
(Contributed by Antoine Pitrou.)
|
(Contributed by Antoine Pitrou.) Memory usage is reduced
|
||||||
|
by using pymalloc for the Unicode string's data.
|
||||||
|
|
||||||
|
* The ``with`` statement now stores the :meth:`__exit__` method on the stack,
|
||||||
|
producing a small speedup. (Implemented by Nick Coghlan.)
|
||||||
|
|
||||||
* To reduce memory usage, the garbage collector will now clear internal
|
* To reduce memory usage, the garbage collector will now clear internal
|
||||||
free lists when garbage-collecting the highest generation of objects.
|
free lists when garbage-collecting the highest generation of objects.
|
||||||
|
@ -1047,6 +1184,13 @@ complete list of changes, or look through the CVS logs for all the details.
|
||||||
Insert mode is enabled by supplying a true value for the *insert_mode*
|
Insert mode is enabled by supplying a true value for the *insert_mode*
|
||||||
parameter when creating the :class:`Textbox` instance.
|
parameter when creating the :class:`Textbox` instance.
|
||||||
|
|
||||||
|
* The :mod:`datetime` module's :meth:`strftime` methods now support a
|
||||||
|
``%f`` format code that expands to the number of microseconds in the
|
||||||
|
object, zero-padded on
|
||||||
|
the left to six places. (Contributed by XXX.)
|
||||||
|
|
||||||
|
.. Patch 1158
|
||||||
|
|
||||||
* The :mod:`decimal` module was updated to version 1.66 of
|
* The :mod:`decimal` module was updated to version 1.66 of
|
||||||
`the General Decimal Specification <http://www2.hursley.ibm.com/decimal/decarith.html>`__. New features
|
`the General Decimal Specification <http://www2.hursley.ibm.com/decimal/decarith.html>`__. New features
|
||||||
include some methods for some basic mathematical functions such as
|
include some methods for some basic mathematical functions such as
|
||||||
|
@ -1097,14 +1241,19 @@ complete list of changes, or look through the CVS logs for all the details.
|
||||||
|
|
||||||
* The :mod:`gopherlib` module has been removed.
|
* The :mod:`gopherlib` module has been removed.
|
||||||
|
|
||||||
* A new function in the :mod:`heapq` module: ``merge(iter1, iter2, ...)``
|
* A new function in the :mod:`heapq` module: ``merge(iter1, iter2, ...)``
|
||||||
takes any number of iterables that return data *in sorted order*, and returns
|
takes any number of iterables that return data *in sorted
|
||||||
a new iterator that returns the contents of all the iterators, also in sorted
|
order*, and returns a new iterator that returns the contents of all
|
||||||
order. For example::
|
the iterators, also in sorted order. For example::
|
||||||
|
|
||||||
heapq.merge([1, 3, 5, 9], [2, 8, 16]) ->
|
heapq.merge([1, 3, 5, 9], [2, 8, 16]) ->
|
||||||
[1, 2, 3, 5, 8, 9, 16]
|
[1, 2, 3, 5, 8, 9, 16]
|
||||||
|
|
||||||
|
Another new function, ``heappushpop(heap, item)``,
|
||||||
|
pushes *item* onto *heap*, then pops off and returns the smallest item.
|
||||||
|
This is more efficient than making a call to :func:`heappush` and then
|
||||||
|
:func:`heappop`.
|
||||||
|
|
||||||
(Contributed by Raymond Hettinger.)
|
(Contributed by Raymond Hettinger.)
|
||||||
|
|
||||||
* An optional ``timeout`` parameter was added to the
|
* An optional ``timeout`` parameter was added to the
|
||||||
|
@ -1157,7 +1306,7 @@ complete list of changes, or look through the CVS logs for all the details.
|
||||||
(2, 3, 1, 3), (2, 3, 1, 4), (2, 3, 2, 3), (2, 3, 2, 4),
|
(2, 3, 1, 3), (2, 3, 1, 4), (2, 3, 2, 3), (2, 3, 2, 4),
|
||||||
(2, 4, 1, 3), (2, 4, 1, 4), (2, 4, 2, 3), (2, 4, 2, 4)]
|
(2, 4, 1, 3), (2, 4, 1, 4), (2, 4, 2, 3), (2, 4, 2, 4)]
|
||||||
|
|
||||||
``combinations(iter, r)`` returns sub-sequences of length *r* from
|
``combinations(iterable, r)`` returns sub-sequences of length *r* from
|
||||||
the elements of *iterable*. ::
|
the elements of *iterable*. ::
|
||||||
|
|
||||||
itertools.combinations('123', 2) ->
|
itertools.combinations('123', 2) ->
|
||||||
|
@ -1678,6 +1827,11 @@ Changes to Python's build process and to the C API include:
|
||||||
See the :file:`PCbuild9` directory for the build files.
|
See the :file:`PCbuild9` directory for the build files.
|
||||||
(Implemented by Christian Heimes.)
|
(Implemented by Christian Heimes.)
|
||||||
|
|
||||||
|
* Python now can only be compiled with C89 compilers (after 19
|
||||||
|
years!). This means that the Python source tree can now drop its
|
||||||
|
own implementations of :cfunc:`memmove` and :cfunc:`strerror`, which
|
||||||
|
are in the C89 standard library.
|
||||||
|
|
||||||
* The BerkeleyDB module now has a C API object, available as
|
* The BerkeleyDB module now has a C API object, available as
|
||||||
``bsddb.db.api``. This object can be used by other C extensions
|
``bsddb.db.api``. This object can be used by other C extensions
|
||||||
that wish to use the :mod:`bsddb` module for their own purposes.
|
that wish to use the :mod:`bsddb` module for their own purposes.
|
||||||
|
@ -1832,6 +1986,15 @@ code:
|
||||||
|
|
||||||
.. Issue 1330538
|
.. Issue 1330538
|
||||||
|
|
||||||
|
* In 3.0-warning mode, inequality comparisons between two dictionaries
|
||||||
|
or two objects that don't implement comparison methods are reported
|
||||||
|
as warnings. ``dict1 == dict2`` still works, but ``dict1 < dict2``
|
||||||
|
is being phased out.
|
||||||
|
|
||||||
|
Comparisons between cells, which are an implementation detail of Python's
|
||||||
|
scoping rules, also cause warnings because such comparisons are forbidden
|
||||||
|
entirely in 3.0.
|
||||||
|
|
||||||
.. ======================================================================
|
.. ======================================================================
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@
|
||||||
|
|
||||||
__copyright__ = """
|
__copyright__ = """
|
||||||
Copyright (c) 1999-2000, Marc-Andre Lemburg; mailto:mal@lemburg.com
|
Copyright (c) 1999-2000, Marc-Andre Lemburg; mailto:mal@lemburg.com
|
||||||
Copyright (c) 2000-2007, eGenix.com Software GmbH; mailto:info@egenix.com
|
Copyright (c) 2000-2008, eGenix.com Software GmbH; mailto:info@egenix.com
|
||||||
|
|
||||||
Permission to use, copy, modify, and distribute this software and its
|
Permission to use, copy, modify, and distribute this software and its
|
||||||
documentation for any purpose and without fee or royalty is hereby granted,
|
documentation for any purpose and without fee or royalty is hereby granted,
|
||||||
|
@ -525,7 +525,13 @@ def _win32_getvalue(key,name,default=''):
|
||||||
In case this fails, default is returned.
|
In case this fails, default is returned.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from win32api import RegQueryValueEx
|
try:
|
||||||
|
# Use win32api if available
|
||||||
|
from win32api import RegQueryValueEx
|
||||||
|
except ImportError:
|
||||||
|
# On Python 2.0 and later, emulate using _winreg
|
||||||
|
import _winreg
|
||||||
|
RegQueryValueEx = _winreg.QueryValueEx
|
||||||
try:
|
try:
|
||||||
return RegQueryValueEx(key,name)
|
return RegQueryValueEx(key,name)
|
||||||
except:
|
except:
|
||||||
|
@ -545,9 +551,9 @@ def win32_ver(release='',version='',csd='',ptype=''):
|
||||||
means the OS version uses debugging code, i.e. code that
|
means the OS version uses debugging code, i.e. code that
|
||||||
checks arguments, ranges, etc. (Thomas Heller).
|
checks arguments, ranges, etc. (Thomas Heller).
|
||||||
|
|
||||||
Note: this function only works if Mark Hammond's win32
|
Note: this function works best with Mark Hammond's win32
|
||||||
package is installed and obviously only runs on Win32
|
package installed, but also on Python 2.3 and later. It
|
||||||
compatible platforms.
|
obviously only runs on Win32 compatible platforms.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# XXX Is there any way to find out the processor type on WinXX ?
|
# XXX Is there any way to find out the processor type on WinXX ?
|
||||||
|
@ -561,11 +567,29 @@ def win32_ver(release='',version='',csd='',ptype=''):
|
||||||
# Import the needed APIs
|
# Import the needed APIs
|
||||||
try:
|
try:
|
||||||
import win32api
|
import win32api
|
||||||
|
from win32api import RegQueryValueEx, RegOpenKeyEx, \
|
||||||
|
RegCloseKey, GetVersionEx
|
||||||
|
from win32con import HKEY_LOCAL_MACHINE, VER_PLATFORM_WIN32_NT, \
|
||||||
|
VER_PLATFORM_WIN32_WINDOWS, VER_NT_WORKSTATION
|
||||||
except ImportError:
|
except ImportError:
|
||||||
return release,version,csd,ptype
|
# Emulate the win32api module using Python APIs
|
||||||
from win32api import RegQueryValueEx,RegOpenKeyEx,RegCloseKey,GetVersionEx
|
try:
|
||||||
from win32con import HKEY_LOCAL_MACHINE,VER_PLATFORM_WIN32_NT,\
|
sys.getwindowsversion
|
||||||
VER_PLATFORM_WIN32_WINDOWS
|
except AttributeError:
|
||||||
|
# No emulation possible, so return the defaults...
|
||||||
|
return release,version,csd,ptype
|
||||||
|
else:
|
||||||
|
# Emulation using _winreg (added in Python 2.0) and
|
||||||
|
# sys.getwindowsversion() (added in Python 2.3)
|
||||||
|
import _winreg
|
||||||
|
GetVersionEx = sys.getwindowsversion
|
||||||
|
RegQueryValueEx = _winreg.QueryValueEx
|
||||||
|
RegOpenKeyEx = _winreg.OpenKeyEx
|
||||||
|
RegCloseKey = _winreg.CloseKey
|
||||||
|
HKEY_LOCAL_MACHINE = _winreg.HKEY_LOCAL_MACHINE
|
||||||
|
VER_PLATFORM_WIN32_WINDOWS = 1
|
||||||
|
VER_PLATFORM_WIN32_NT = 2
|
||||||
|
VER_NT_WORKSTATION = 1
|
||||||
|
|
||||||
# Find out the registry key and some general version infos
|
# Find out the registry key and some general version infos
|
||||||
maj,min,buildno,plat,csd = GetVersionEx()
|
maj,min,buildno,plat,csd = GetVersionEx()
|
||||||
|
@ -602,11 +626,18 @@ def win32_ver(release='',version='',csd='',ptype=''):
|
||||||
elif maj == 6:
|
elif maj == 6:
|
||||||
if min == 0:
|
if min == 0:
|
||||||
# Per http://msdn2.microsoft.com/en-us/library/ms724429.aspx
|
# Per http://msdn2.microsoft.com/en-us/library/ms724429.aspx
|
||||||
productType = GetVersionEx(1)[8]
|
try:
|
||||||
if productType == 1: # VER_NT_WORKSTATION
|
productType = GetVersionEx(1)[8]
|
||||||
|
except TypeError:
|
||||||
|
# sys.getwindowsversion() doesn't take any arguments, so
|
||||||
|
# we cannot detect 2008 Server that way.
|
||||||
|
# XXX Add some other means of detecting 2008 Server ?!
|
||||||
release = 'Vista'
|
release = 'Vista'
|
||||||
else:
|
else:
|
||||||
release = '2008Server'
|
if productType == VER_NT_WORKSTATION:
|
||||||
|
release = 'Vista'
|
||||||
|
else:
|
||||||
|
release = '2008Server'
|
||||||
else:
|
else:
|
||||||
release = 'post2008Server'
|
release = 'post2008Server'
|
||||||
else:
|
else:
|
||||||
|
@ -617,9 +648,9 @@ def win32_ver(release='',version='',csd='',ptype=''):
|
||||||
|
|
||||||
# Open the registry key
|
# Open the registry key
|
||||||
try:
|
try:
|
||||||
keyCurVer = RegOpenKeyEx(HKEY_LOCAL_MACHINE,regkey)
|
keyCurVer = RegOpenKeyEx(HKEY_LOCAL_MACHINE, regkey)
|
||||||
# Get a value to make sure the key exists...
|
# Get a value to make sure the key exists...
|
||||||
RegQueryValueEx(keyCurVer,'SystemRoot')
|
RegQueryValueEx(keyCurVer, 'SystemRoot')
|
||||||
except:
|
except:
|
||||||
return release,version,csd,ptype
|
return release,version,csd,ptype
|
||||||
|
|
||||||
|
@ -1044,10 +1075,12 @@ def uname():
|
||||||
release,version,csd,ptype = win32_ver()
|
release,version,csd,ptype = win32_ver()
|
||||||
if release and version:
|
if release and version:
|
||||||
use_syscmd_ver = 0
|
use_syscmd_ver = 0
|
||||||
# XXX Should try to parse the PROCESSOR_* environment variables
|
# Try to use the PROCESSOR_* environment variables
|
||||||
# available on Win XP and later; see
|
# available on Win XP and later; see
|
||||||
# http://support.microsoft.com/kb/888731 and
|
# http://support.microsoft.com/kb/888731 and
|
||||||
# http://www.geocities.com/rick_lively/MANUALS/ENV/MSWIN/PROCESSI.HTM
|
# http://www.geocities.com/rick_lively/MANUALS/ENV/MSWIN/PROCESSI.HTM
|
||||||
|
machine = os.environ.get('PROCESSOR_ARCHITECTURE', '')
|
||||||
|
processor = os.environ.get('PROCESSOR_IDENTIFIER', machine)
|
||||||
|
|
||||||
# Try the 'ver' system command available on some
|
# Try the 'ver' system command available on some
|
||||||
# platforms
|
# platforms
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
"""Test correct operation of the print function.
|
"""Test correct operation of the print function.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# In 2.6, this gives us the behavior we want. In 3.0, it has
|
||||||
|
# no function, but it still must parse correctly.
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
|
@ -17,6 +17,9 @@ the format to accommodate documentation needs as they arise.
|
||||||
Permissions History
|
Permissions History
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
- Jerry Seutter was given SVN access on 20 March 2008 by BAC, for
|
||||||
|
general contributions to Python.
|
||||||
|
|
||||||
- Jeff Rush was given SVN access on 18 March 2008 by AMK, for Distutils work.
|
- Jeff Rush was given SVN access on 18 March 2008 by AMK, for Distutils work.
|
||||||
|
|
||||||
- David Wolever was given SVN access on 17 March 2008 by MvL,
|
- David Wolever was given SVN access on 17 March 2008 by MvL,
|
||||||
|
|
Loading…
Reference in New Issue