## Contents

- 1 PEP 308: Conditional Expressions
- 2 PEP 309: Partial Function Application
- 3 PEP 314: Metadata for Python Software Packages v1.1
- 4 PEP 328: Absolute and Relative Imports
- 5 PEP 338: Executing Modules as Scripts
- 6 PEP 341: Unified try/except/finally
- 7 PEP 342: New Generator Features
- 8 PEP 343: The 'with' statement
  - 8.1 Writing Context Managers
  - 8.2 The contextlib module
- 9 PEP 352: Exceptions as New-Style Classes
- 10 PEP 353: Using ssize_t as the index type
- 11 PEP 357: The '__index__' method
- 12 Other Language Changes
  - 12.1 Interactive Interpreter Changes
  - 12.2 Optimizations
- 13 New, Improved, and Removed Modules
  - 13.1 The ctypes package
  - 13.2 The ElementTree package
  - 13.3 The hashlib package
  - 13.4 The sqlite3 package
  - 13.5 The wsgiref package
- 14 Build and C API Changes
  - 14.1 Port-Specific Changes
- 15 Porting to Python 2.5
- 16 Acknowledgements

This article explains the new features in Python 2.5. The final release of Python 2.5 is scheduled for August 2006; PEP 356 describes the planned release schedule.

The changes in Python 2.5 are an interesting mix of language and library improvements. The library enhancements will be more important to Python's user community, I think, because several widely-useful packages were added. New modules include ElementTree for XML processing (section 13.2), the SQLite database module (section 13.4), and the `ctypes` module for calling C functions (section 13.1).

The language changes are of middling significance. Some pleasant new features were added, but most of them aren't features that you'll use every day. Conditional expressions were finally added to the language using a novel syntax; see section 1. The new '`with`' statement will make writing cleanup code easier (section 8). Values can now be passed into generators (section 7). Imports are now visible as either absolute or relative (section 4). Some corner cases of exception handling are handled better (section 6). All these improvements are worthwhile, but they're improvements to one specific language feature or another; none of them are broad modifications to Python's semantics.

As well as the language and library additions, other improvements and bugfixes were made throughout the source tree. A search through the SVN change logs finds there were 353 patches applied and 458 bugs fixed between Python 2.4 and 2.5. (Both figures are likely to be underestimates.)

This article doesn't try to be a complete specification of the new features; instead changes are briefly introduced using helpful examples. For full details, you should always refer to the documentation for Python 2.5 at http://docs.python.org. If you want to understand the complete implementation and design rationale, refer to the PEP for a particular new feature.

Comments, suggestions, and error reports for this document are welcome; please e-mail them to the author or open a bug in the Python bug tracker.