I was wondering what was going on in the Python trunk so I made myself skim through the NEWS to see what’s new. Let’s see:
- Float arguments to seek() are now deprecated:
[code lang="python"]
open(’t.txt’, ‘w’)
f = _ f.write(’sample\n’) f.seek(0.0) main:1: DeprecationWarning: integer argument expected, got float [/code]
WindowsError correctly displays the windows error code instead of the POSIX one.
The break statement inside a try statement results in a SyntaxError:
[code lang="python"]
try: … break … except: … pass … File “
“, line 2 SyntaxError: ‘break’ outside loop [/code]
with and as are now reserved keywords
You can now use heapq.merge() to merge sorted iterables into a single one without pulling all the memory at once:
[code lang="python"]
from heapq import merge a = [1, 3, 5, 7, 9, 11, 13, 15] b = [0, 2, 4, 6, 8, 10, 12, 14] merged = merge(a, b) for item in merged: print item, … 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 [/code]
- itertools.izip_longest() has been added to zip sequences with different lengths:
[code lang="python"]
zip(range(10), range(10)) [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9)] zip(range(10), range(11)) [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9)] [/code]
Notice the additional elements are simply discarded with zip/izip
[code lang="python"]
from itertools import izip_longest for couple in izip_longest(range(10), range(20)): print couple, … (0, 0) (1, 1) (2, 2) (3, 3) (4, 4) (5, 5) (6, 6) (7, 7) (8,
(9, 9) (None, 10) (None, 11) (None, 12) (None, 13) (None, 14) (None, 15) (None, 16) (None, 17) (None, 18) (None, 19) for couple in izip_longest(range(10), range(20), fillvalue=0): print couple, … (0, 0) (1, 1) (2, 2) (3, 3) (4, 4) (5, 5) (6, 6) (7, 7) (8,
(9, 9) (0, 10) (0, 11) (0, 12) (0, 13) (0, 14) (0, 15) (0, 16) (0, 17) (0, 18) (0, 19) [/code]
izip_longest fills in the missing values with None by default but you can provide your own fillvalue
zipfile module has been improved and now supports decryption.
Support for IronPython and Jython has been added to the platform module.
The module sets has been deprecated in favor of set/frozenset builtin types.
Support for MSVC 8 was added to bdist_wininst
If your platform does have ‘chflags’ and/or ‘lchflags’ syscall you can take advantage of it now.
Support for HCI protocol on Bluetooth sockets has been added.
There’s a lot, lot more to list go to the NEWS file on the trunk to stay up to date.

