diff options
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/conf.py | 85 | ||||
-rw-r--r-- | Doc/howto/curses.rst | 6 | ||||
-rw-r--r-- | Doc/library/collections.rst | 3 | ||||
-rw-r--r-- | Doc/library/itertools.rst | 11 | ||||
-rw-r--r-- | Doc/library/msilib.rst | 2 | ||||
-rw-r--r-- | Doc/library/queue.rst | 7 | ||||
-rw-r--r-- | Doc/library/sched.rst | 35 | ||||
-rw-r--r-- | Doc/library/smtplib.rst | 26 | ||||
-rw-r--r-- | Doc/library/socket.rst | 2 | ||||
-rw-r--r-- | Doc/tools/sphinx-build.py | 13 | ||||
-rw-r--r-- | Doc/tools/sphinxext/download.html | 53 | ||||
-rw-r--r-- | Doc/tools/sphinxext/indexcontent.html | 56 | ||||
-rw-r--r-- | Doc/tools/sphinxext/indexsidebar.html | 19 | ||||
-rw-r--r-- | Doc/whatsnew/2.6.rst | 124 |
14 files changed, 412 insertions, 30 deletions
diff --git a/Doc/conf.py b/Doc/conf.py index 29137e2..5be5d1e 100644 --- a/Doc/conf.py +++ b/Doc/conf.py @@ -2,22 +2,28 @@ # # Python documentation build configuration file # +# This file is execfile()d with the current directory set to its containing dir. +# # The contents of this file are pickled, so don't put values in the namespace # that aren't pickleable (module imports are okay, they're removed automatically). # General configuration # --------------------- +# General substitutions. +project = 'Python' +copyright = '1990-2007, Python Software Foundation' + # The default replacements for |version| and |release|. -# If 'auto', Sphinx looks for the Include/patchlevel.h file in the current Python +# If '<auto>', Sphinx looks for the Include/patchlevel.h file in the current Python # source tree and replaces the values accordingly. # # The short X.Y version. # version = '2.6' -version = 'auto' +version = '<auto>' # The full version, including alpha/beta/rc tags. # release = '2.6a0' -release = 'auto' +release = '<auto>' # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: @@ -39,6 +45,9 @@ unused_files = [ 'library/xml.etree.rst', ] +# Relative filename of the reference count data file. +refcount_file = 'data/refcounts.dat' + # If true, '()' will be appended to :func: etc. cross-reference text. add_function_parentheses = True @@ -50,9 +59,6 @@ add_module_names = True # Options for HTML output # ----------------------- -# The base URL for download links. -html_download_base_url = 'http://docs.python.org/ftp/python/doc/' - # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. html_last_updated_fmt = '%b %d, %Y' @@ -61,12 +67,71 @@ html_last_updated_fmt = '%b %d, %Y' # typographically correct entities. html_use_smartypants = True +# Content template for the index page, filename relative to this file. +html_index = 'tools/sphinxext/indexcontent.html' + +# Custom sidebar templates, filenames relative to this file. +html_sidebars = { + 'index': 'tools/sphinxext/indexsidebar.html', +} + +# Additional templates that should be rendered to pages. +html_additional_pages = { + 'download': 'tools/sphinxext/download.html', +} + +# Output file base name for HTML help builder. +htmlhelp_basename = 'pydoc' + # Options for LaTeX output # ------------------------ -# The paper size ("letter" or "a4"). -latex_paper_size = "a4" +# The paper size ('letter' or 'a4'). +latex_paper_size = 'a4' + +# The font size ('10pt', '11pt' or '12pt'). +latex_font_size = '10pt' + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, document class [howto/manual]). +_stdauthor = r'Guido van Rossum\\Fred L. Drake, Jr., editor' +latex_documents = [ + ('c-api/index.rst', 'c-api.tex', + 'The Python/C API', _stdauthor, 'manual'), + ('distutils/index.rst', 'distutils.tex', + 'Distributing Python Modules', _stdauthor, 'manual'), + ('documenting/index.rst', 'documenting.tex', + 'Documenting Python', 'Georg Brandl', 'manual'), + ('extending/index.rst', 'extending.tex', + 'Extending and Embedding Python', _stdauthor, 'manual'), + ('install/index.rst', 'install.tex', + 'Installing Python Modules', _stdauthor, 'manual'), + ('library/index.rst', 'library.tex', + 'The Python Library Reference', _stdauthor, 'manual'), + ('reference/index.rst', 'reference.tex', + 'The Python Language Reference', _stdauthor, 'manual'), + ('tutorial/index.rst', 'tutorial.tex', + 'Python Tutorial', _stdauthor, 'manual'), + ('using/index.rst', 'using.tex', + 'Using Python', _stdauthor, 'manual'), + ('whatsnew/' + version + '.rst', 'whatsnew.tex', + 'What\'s New in Python', 'A. M. Kuchling', 'howto'), +] +# Collect all HOWTOs individually +import os +latex_documents.extend(('howto/' + fn, 'howto-' + fn[:-4] + '.tex', + 'HOWTO', _stdauthor, 'howto') + for fn in os.listdir('howto') + if fn.endswith('.rst') and fn != 'index.rst') + +# Additional stuff for the LaTeX preamble. +latex_preamble = r''' +\authoraddress{ + \strong{Python Software Foundation}\\ + Email: \email{docs@python.org} +} +''' -# The font size ("10pt", "11pt" or "12pt"). -latex_font_size = "10pt" +# Documents to append as an appendix to all manuals. +latex_appendices = ['glossary.rst', 'about.rst', 'license.rst', 'copyright.rst'] diff --git a/Doc/howto/curses.rst b/Doc/howto/curses.rst index 6f53708..12fb936 100644 --- a/Doc/howto/curses.rst +++ b/Doc/howto/curses.rst @@ -3,7 +3,7 @@ ********************************** :Author: A.M. Kuchling, Eric S. Raymond -:Release: 2.02 +:Release: 2.03 .. topic:: Abstract @@ -367,8 +367,8 @@ It's possible to change this behavior with the method :meth:`nodelay`. After ``nodelay(1)``, :meth:`getch` for the window becomes non-blocking and returns ``curses.ERR`` (a value of -1) when no input is ready. There's also a :func:`halfdelay` function, which can be used to (in effect) set a timer on each -:meth:`getch`; if no input becomes available within the number of milliseconds -specified as the argument to :func:`halfdelay`, curses raises an exception. +:meth:`getch`; if no input becomes available within a specified +delay (measured in tenths of a second), curses raises an exception. The :meth:`getch` method returns an integer; if it's between 0 and 255, it represents the ASCII code of the key pressed. Values greater than 255 are diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst index f1a8fff..cbc9c6b 100644 --- a/Doc/library/collections.rst +++ b/Doc/library/collections.rst @@ -566,6 +566,9 @@ faster versions that bypass error-checking:: def _replace(self, _map=map, **kwds): return self._make(_map(kwds.get, ('x', 'y'), self)) +The subclasses shown above set ``__slots__`` to an empty tuple. This keeps +keep memory requirements low by preventing the creation of instance dictionaries. + Subclassing is not useful for adding new, stored fields. Instead, simply create a new named tuple type from the :attr:`_fields` attribute:: diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst index 21f6476..ca2b1ff 100644 --- a/Doc/library/itertools.rst +++ b/Doc/library/itertools.rst @@ -319,16 +319,19 @@ loops that truncate the stream. .. function:: starmap(function, iterable) - Make an iterator that computes the function using arguments tuples obtained from + Make an iterator that computes the function using arguments obtained from the iterable. Used instead of :func:`imap` when argument parameters are already grouped in tuples from a single iterable (the data has been "pre-zipped"). The difference between :func:`imap` and :func:`starmap` parallels the distinction between ``function(a,b)`` and ``function(*c)``. Equivalent to:: def starmap(function, iterable): - iterable = iter(iterable) - while True: - yield function(*next(iterable)) + for args in iterable: + yield function(*args) + + .. versionchanged:: 2.6 + Previously, :func:`starmap` required the function arguments to be tuples. + Now, any iterable is allowed. .. function:: takewhile(predicate, iterable) diff --git a/Doc/library/msilib.rst b/Doc/library/msilib.rst index 93e7b84..35e472c 100644 --- a/Doc/library/msilib.rst +++ b/Doc/library/msilib.rst @@ -146,7 +146,7 @@ Database Objects .. seealso:: - `MSIOpenView <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msiopenview.asp>`_ + `MSIDatabaseOpenView <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msidatabaseopenview.asp>`_ `MSIDatabaseCommit <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msidatabasecommit.asp>`_ `MSIGetSummaryInformation <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msigetsummaryinformation.asp>`_ diff --git a/Doc/library/queue.rst b/Doc/library/queue.rst index 5442a76..582f2cd 100644 --- a/Doc/library/queue.rst +++ b/Doc/library/queue.rst @@ -29,6 +29,7 @@ The :mod:`Queue` module defines the following classes and exceptions: block once this size has been reached, until queue items are consumed. If *maxsize* is less than or equal to zero, the queue size is infinite. + .. class:: LifoQueue(maxsize) Constructor for a LIFO queue. *maxsize* is an integer that sets the upperbound @@ -36,6 +37,9 @@ The :mod:`Queue` module defines the following classes and exceptions: block once this size has been reached, until queue items are consumed. If *maxsize* is less than or equal to zero, the queue size is infinite. + .. versionadded:: 2.6 + + .. class:: PriorityQueue(maxsize) Constructor for a priority queue. *maxsize* is an integer that sets the upperbound @@ -47,6 +51,9 @@ The :mod:`Queue` module defines the following classes and exceptions: one returned by ``sorted(list(entries))[0]``). A typical pattern for entries is a tuple in the form: ``(priority_number, data)``. + .. versionadded:: 2.6 + + .. exception:: Empty Exception raised when non-blocking :meth:`get` (or :meth:`get_nowait`) is called diff --git a/Doc/library/sched.rst b/Doc/library/sched.rst index 57f9b5c..5dfa456 100644 --- a/Doc/library/sched.rst +++ b/Doc/library/sched.rst @@ -41,13 +41,39 @@ Example:: From print_time 930343700.273 930343700.276 +In multi-threaded environments, the :class:`scheduler` class has limitations +with respect to thread-safety, inability to insert a new task before +the one currently pending in a running scheduler, and holding up the main +thread until the event queue is empty. Instead, the preferred approach +is to use the :class:`threading.Timer` class instead. + +Example:: + + >>> import time + >>> from threading import Timer + >>> def print_time(): + ... print "From print_time", time.time() + ... + >>> def print_some_times(): + ... print time.time() + ... Timer(5, print_time, ()).start() + ... Timer(10, print_time, ()).start() + ... time.sleep(11) # sleep while time-delay events execute + ... print time.time() + ... + >>> print_some_times() + 930343690.257 + From print_time 930343695.274 + From print_time 930343700.273 + 930343701.301 + .. _scheduler-objects: Scheduler Objects ----------------- -:class:`scheduler` instances have the following methods: +:class:`scheduler` instances have the following methods and attributes: .. method:: scheduler.enterabs(time, priority, action, argument) @@ -98,3 +124,10 @@ Scheduler Objects the calling code is responsible for canceling events which are no longer pertinent. +.. attribute:: scheduler.queue + + Read-only attribute returning a list of upcoming events in the order they + will be run. Each event is shown as a :term:`named tuple` with the + following fields: time, priority, action, argument. + + .. versionadded:: 2.6 diff --git a/Doc/library/smtplib.rst b/Doc/library/smtplib.rst index 790cacb..1ffe812 100644 --- a/Doc/library/smtplib.rst +++ b/Doc/library/smtplib.rst @@ -184,6 +184,16 @@ An :class:`SMTP` instance has the following methods: necessary to call this method explicitly. It will be implicitly called by :meth:`sendmail` when necessary. +.. method:: SMTP.ehlo_or_helo_if_needed() + + This method call :meth:`ehlo` and or :meth:`helo` if there has been no + previous ``EHLO`` or ``HELO`` command this session. It tries ESMTP ``EHLO`` + first. + + :exc:SMTPHeloError + The server didn't reply properly to the ``HELO`` greeting. + + .. versionadded:: 2.6 .. method:: SMTP.has_extn(name) @@ -230,6 +240,22 @@ An :class:`SMTP` instance has the following methods: If *keyfile* and *certfile* are provided, these are passed to the :mod:`socket` module's :func:`ssl` function. + If there has been no previous ``EHLO`` or ``HELO`` command this session, + this method tries ESMTP ``EHLO`` first. + + .. versionchanged:: 2.6 + + :exc:`SMTPHeloError` + The server didn't reply properly to the ``HELO`` greeting. + + :exc:`SMTPException` + The server does not support the STARTTLS extension. + + .. versionchanged:: 2.6 + + :exc:`RuntimeError` + SSL/TLS support is not available to your python interpreter. + .. method:: SMTP.sendmail(from_addr, to_addrs, msg[, mail_options, rcpt_options]) diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst index 406c136..7d2dea0 100644 --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -562,7 +562,7 @@ correspond to Unix system calls applicable to sockets. :platform: Windows - The `meth:ioctl` method is a limited interface to the WSAIoctl system + The :meth:`ioctl` method is a limited interface to the WSAIoctl system interface. Please refer to the MSDN documentation for more information. diff --git a/Doc/tools/sphinx-build.py b/Doc/tools/sphinx-build.py index ab9f40d..d72a831 100644 --- a/Doc/tools/sphinx-build.py +++ b/Doc/tools/sphinx-build.py @@ -11,12 +11,13 @@ import sys if __name__ == '__main__': - if not (2, 5, 1) <= sys.version_info[:3] < (3, 0, 0): - sys.stderr.write("""\ -Error: Sphinx needs to be executed with Python 2.5.1 or newer (not 3.0 though). -If you run this from the Makefile, you can set the PYTHON variable to the path -of an alternative interpreter executable, e.g., ``make html PYTHON=python2.5``.) -""") + if sys.version_info[:3] < (2, 4, 0): + print("""\ +Error: Sphinx needs to be executed with Python 2.4 or newer (not 3.0 though). +(If you run this from the Makefile, you can set the PYTHON variable +to the path of an alternative interpreter executable, e.g., +``make html PYTHON=python2.5``). +""", file=sys.stderr) sys.exit(1) from sphinx import main diff --git a/Doc/tools/sphinxext/download.html b/Doc/tools/sphinxext/download.html new file mode 100644 index 0000000..f6a593a --- /dev/null +++ b/Doc/tools/sphinxext/download.html @@ -0,0 +1,53 @@ +{% extends "layout.html" %} +{% set title = 'Download' %} +{% block body %} + +<h1>Download Python {{ release }} Documentation + {%- if last_updated %} (last updated on {{ last_updated }}){% endif %}</h1> + +<p>To download an archive containing all the documents for this version of +Python in one of various formats, follow one of links in this table. The numbers +in the table are the size of the download files in Kilobytes.</p> + +{# XXX download links #} + + +<p>These archives contain all the content in the documentation section.</p> + +<h2>Unpacking</h2> + +<p>Unix users should download the .tar.bz2 archives; these are bzipped tar +archives and can be handled in the usual way using tar and the bzip2 +program. The <a href="http://www.info-zip.org">InfoZIP</a> unzip program can be +used to handle the ZIP archives if desired. The .tar.bz2 archives provide the +best compression and fastest download times.</p> + +<p>Windows users can use the ZIP archives since those are customary on that +platform. These are created on Unix using the InfoZIP zip program. They may be +unpacked using the free WiZ tool (from the InfoZIP developers) or any other +tool for handling ZIP archives; any of them should work.</p> + +<p>Note that the .tar.bz2 files are smaller than the other archives; Windows +users may want to install the bzip2 tools on their systems as well. Windows +binaries for a command-line tool are available at <a +href="http://www.bzip.org">The bzip2 and libbzip2 official home page</a>, but +most other archiving utilities support the tar and bzip2 formats as well.</p> + + +<h2>Problems</h2> + +<p><strong>Printing PDFs using Adobe Acrobat Reader 5.0:</strong> Adobe has +reportedly admitted that there is a bug in Acrobat Reader 5.0 which causes it +not to print at least some PDF files generated by pdfTeX. This software is used +to produce the PDF version of the Python documentation, and our documents +definately trigger this bug in Acrobat Reader. To print the PDF files, use +Acrobat Reader 4.x, ghostscript, or xpdf.</p> + +<p>Reportedly, Acrobat Reader 6.0 can print these documents without this +problem, but we've not yet had an opportunity to confirm the report. Sadly, +version 6.0 is not yet available on Unix platforms.</p> + +<p>If you have comments or suggestions for the Python documentation, please send +email to <a href="docs@python.org">docs@python.org</a>.</p> + +{% endblock %} diff --git a/Doc/tools/sphinxext/indexcontent.html b/Doc/tools/sphinxext/indexcontent.html new file mode 100644 index 0000000..218f346 --- /dev/null +++ b/Doc/tools/sphinxext/indexcontent.html @@ -0,0 +1,56 @@ + <p><strong>Parts of the documentation:</strong></p> + <table class="contentstable" align="center"><tr> + <td width="50%"> + <p class="biglink"><a class="biglink" href="{{ pathto("whatsnew/" + version) }}">What's new in Python {{ version }}?</a><br> + <span class="linkdescr">changes since previous major release</span></p> + <p class="biglink"><a class="biglink" href="{{ pathto("tutorial/index") }}">Tutorial</a><br> + <span class="linkdescr">start here</span></p> + <p class="biglink"><a class="biglink" href="{{ pathto("using/index") }}">Using Python</a><br> + <span class="linkdescr">how to use Python on different platforms</span></p> + <p class="biglink"><a class="biglink" href="{{ pathto("reference/index") }}">Language Reference</a><br> + <span class="linkdescr">describes syntax and language elements</span></p> + <p class="biglink"><a class="biglink" href="{{ pathto("library/index") }}">Library Reference</a><br> + <span class="linkdescr">keep this under your pillow</span></p> + <p class="biglink"><a class="biglink" href="{{ pathto("howto/index") }}">Python HOWTOs</a><br> + <span class="linkdescr">in-depth documents on specific topics</span></p> + </td><td width="50%"> + <p class="biglink"><a class="biglink" href="{{ pathto("extending/index") }}">Extending and Embedding</a><br> + <span class="linkdescr">tutorial for C/C++ programmers</span></p> + <p class="biglink"><a class="biglink" href="{{ pathto("c-api/index") }}">Python/C API</a><br> + <span class="linkdescr">reference for C/C++ programmers</span></p> + <p class="biglink"><a class="biglink" href="{{ pathto("install/index") }}">Installing Python Modules</a><br> + <span class="linkdescr">information for installers & sys-admins</span></p> + <p class="biglink"><a class="biglink" href="{{ pathto("distutils/index") }}">Distributing Python Modules</a><br> + <span class="linkdescr">sharing modules with others</span></p> + <p class="biglink"><a class="biglink" href="{{ pathto("documenting/index") }}">Documenting Python</a><br> + <span class="linkdescr">guide for documentation authors</span></p> + </td></tr> + </table> + + <p><strong>Indices and tables:</strong></p> + <table class="contentstable" align="center"><tr> + <td width="50%"> + <p class="biglink"><a class="biglink" href="{{ pathto("modindex") }}">Global Module Index</a><br> + <span class="linkdescr">quick access to all modules</span></p> + <p class="biglink"><a class="biglink" href="{{ pathto("genindex") }}">General Index</a><br> + <span class="linkdescr">all functions, classes, terms</span></p> + <p class="biglink"><a class="biglink" href="{{ pathto("glossary") }}">Glossary</a><br> + <span class="linkdescr">the most important terms explained</span></p> + </td><td width="50%"> + <p class="biglink"><a class="biglink" href="{{ pathto("search") }}">Search page</a><br> + <span class="linkdescr">search this documentation</span></p> + <p class="biglink"><a class="biglink" href="{{ pathto("contents") }}">Complete Table of Contents</a><br> + <span class="linkdescr">lists all sections and subsections</span></p> + </td></tr> + </table> + + <p><strong>Meta information:</strong></p> + <table class="contentstable" align="center"><tr> + <td width="50%"> + <p class="biglink"><a class="biglink" href="{{ pathto("bugs") }}">Reporting bugs</a></p> + <p class="biglink"><a class="biglink" href="{{ pathto("about") }}">About the documentation</a></p> + </td><td width="50%"> + <p class="biglink"><a class="biglink" href="{{ pathto("license") }}">History and License of Python</a></p> + <p class="biglink"><a class="biglink" href="{{ pathto("copyright") }}">Copyright</a></p> + </td></tr> + </table> diff --git a/Doc/tools/sphinxext/indexsidebar.html b/Doc/tools/sphinxext/indexsidebar.html new file mode 100644 index 0000000..b74c54f --- /dev/null +++ b/Doc/tools/sphinxext/indexsidebar.html @@ -0,0 +1,19 @@ + <h3>Download</h3> + <p><a href="{{ pathto('download') }}">Download these documents</a></p> + <h3>Other resources</h3> + <ul> + {# XXX: many of these should probably be merged in the main docs #} + <li><a href="http://www.python.org/doc/faq/">FAQs</a></li> + <li><a href="http://www.python.org/doc/intros/">Introductions</a></li> + <li><a href="http://www.python.org/doc/essays/">Guido's Essays</a></li> + <li><a href="http://www.python.org/doc/newstyle/">New-style Classes</a></li> + <li><a href="http://www.python.org/dev/peps/">PEP Index</a></li> + <li><a href="http://wiki.python.org/moin/BeginnersGuide">Beginner's Guide</a></li> + <li><a href="http://www.python.org/topics/">Topic Guides</a></li> + <li><a href="http://wiki.python.org/moin/PythonBooks">Book List</a></li> + <li><a href="http://www.python.org/doc/av/">Audio/Visual Talks</a></li> + <li><a href="http://www.python.org/doc/other/">Other Doc Collections</a></li> + <li> </li> + <li><a href="http://www.python.org/doc/versions/">Previous versions</a></li> + <li> </li> + </ul> diff --git a/Doc/whatsnew/2.6.rst b/Doc/whatsnew/2.6.rst index 0539a44..46922a4 100644 --- a/Doc/whatsnew/2.6.rst +++ b/Doc/whatsnew/2.6.rst @@ -541,6 +541,90 @@ an abstract method. Implemented by XXX. Backported to 2.6 by Benjamin Aranguren, with Alex Martelli. +.. ====================================================================== + +.. _pep-3141: + +PEP 3141: A Type Hierarchy for Numbers +===================================================== + +In Python 3.0, several abstract base classes for numeric types, +inspired by Scheme's numeric tower, are being added. +This change was backported to 2.6 as the :mod:`numbers` module. + +The most general ABC is :class:`Number`. It defines no operations at +all, and only exists to allow checking if an object is a number by +doing ``isinstance(obj, Number)``. + +Numbers are further divided into :class:`Exact` and :class:`Inexact`. +Exact numbers can represent values precisely and operations never +round off the results or introduce tiny errors that may break the +communtativity and associativity properties; inexact numbers may +perform such rounding or introduce small errors. Integers, long +integers, and rational numbers are exact, while floating-point +and complex numbers are inexact. + +:class:`Complex` is a subclass of :class:`Number`. Complex numbers +can undergo the basic operations of addition, subtraction, +multiplication, division, and exponentiation, and you can retrieve the +real and imaginary parts and obtain a number's conjugate. Python's built-in +complex type is an implementation of :class:`Complex`. + +:class:`Real` further derives from :class:`Complex`, and adds +operations that only work on real numbers: :func:`floor`, :func:`trunc`, +rounding, taking the remainder mod N, floor division, +and comparisons. + +:class:`Rational` numbers derive from :class:`Real`, have +:attr:`numerator` and :attr:`denominator` properties, and can be +converted to floats. Python 2.6 adds a simple rational-number class +in the :mod:`rational` module. + +:class:`Integral` numbers derive from :class:`Rational`, and +can be shifted left and right with ``<<`` and ``>>``, +combined using bitwise operations such as ``&`` and ``|``, +and can be used as array indexes and slice boundaries. + +In Python 3.0, the PEP slightly redefines the existing built-ins +:func:`math.floor`, :func:`math.ceil`, :func:`round`, and adds a new +one, :func:`trunc`, that's been backported to Python 2.6. +:func:`trunc` rounds toward zero, returning the closest +:class:`Integral` that's between the function's argument and zero. + +.. seealso:: + + XXX link: Discusses Scheme's numeric tower. + + + +The Rational Module +-------------------------------------------------- + +To fill out the hierarchy of numeric types, a rational-number class +has been added as the :mod:`rational` module. Rational numbers are +represented as a fraction; rational numbers can exactly represent +numbers such as two-thirds that floating-point numbers can only +approximate. + +The :class:`Rational` constructor takes two :class:`Integral` values +that will be the numerator and denominator of the resulting fraction. :: + + >>> from rational import Rational + >>> a = Rational(2, 3) + >>> b = Rational(2, 5) + >>> float(a), float(b) + (0.66666666666666663, 0.40000000000000002) + >>> a+b + rational.Rational(16,15) + >>> a/b + rational.Rational(5,3) + +The :mod:`rational` module is based upon an implementation by Sjoerd +Mullender that was in Python's :file:`Demo/classes/` directory for a +long time. This implementation was significantly updated by Jeffrey +Yaskin. + + Other Language Changes ====================== @@ -568,10 +652,10 @@ Here are all of the changes that Python 2.6 makes to the core Python language. .. Revision 57619 -* Properties now have two attributes, +* Properties now have three attributes, :attr:`getter`, :attr:`setter` and :attr:`deleter`, that are useful shortcuts for - adding a setter or deleter function to an existing property. - You would use them like this:: + adding or modifying a getter, setter or deleter function to an + existing property. You would use them like this:: class C(object): @property @@ -586,6 +670,15 @@ Here are all of the changes that Python 2.6 makes to the core Python language. def x(self): del self._x + class D(C): + @C.x.getter + def x(self): + return self._x * 2 + + @x.setter + def x(self, value): + self._x = value / 2 + * C functions and methods that use :cfunc:`PyComplex_AsCComplex` will now accept arguments that @@ -997,6 +1090,12 @@ complete list of changes, or look through the CVS logs for all the details. .. Patch #957003 +* In the :mod:`smtplib` module, SMTP.starttls() now complies with :rfc:`3207` + and forgets any knowledge obtained from the server not obtained from + the TLS negotiation itself. Patch contributed by Bill Fenner. + + .. Issue 829951 + * The :mod:`socket` module now supports TIPC (http://tipc.sf.net), a high-performance non-IP-based protocol designed for use in clustered environments. TIPC addresses are 4- or 5-tuples. @@ -1246,13 +1345,30 @@ Port-Specific Changes: Windows API. The :func:`getwch` function reads a keypress and returns a Unicode value, as does the :func:`getwche` function. The :func:`putwch` function takes a Unicode character and writes it to the console. + (Contributed by Christian Heimes.) + +* :func:`os.path.expandvars` will now expand environment variables + in the form "%var%", and "~user" will be expanded into the + user's home directory path. (Contributed by Josiah Carlson.) + +* The :mod:`socket` module's socket objects now have an + :meth:`ioctl` method that provides a limited interface to the + :cfunc:`WSAIoctl` system interface. * The :mod:`_winreg` module now has a function, :func:`ExpandEnvironmentStrings`, that expands environment variable references such as ``%NAME%`` in an input string. The handle objects provided by this module now support the context protocol, so they can be used - in :keyword:`with` statements. + in :keyword:`with` statements. (Contributed by Christian Heimes.) + +* The new default compiler on Windows is Visual Studio 2008 (VS 9.0). The + build directories for Visual Studio 2003 (VS7.1) and 2005 (VS8.0) + were moved into the PC/ directory. The new PCbuild directory supports + cross compilation for X64, debug builds and Profile Guided Optimization + (PGO). PGO builds are roughly 10% faster than normal builds. + (Contributed by Christian Heimes with help from Amaury Forgeot d'Arc and + Martin von Loewis.) .. ====================================================================== |