views:

287

answers:

5

What features do you think will be most useful in python 2.6 now that it's been released? Can you think of any clever uses to all the new functionality? for example do you see yourself using ABCs, class decorators and multiprocessing? or do you think that the new developments is wont be of much use?

Just want to hear people's opinions.

+2  A: 

JSON support is very nice and will likely make Python a little more popular as a web processing language. Not something that I will use but it is a good feature.

Multiprocessing is great. The feature set looks like they are making a good start. This is very important today with even desktops being multi-core'd at this point but from a server perspective this is absolutely critical in allowing python to scale in the datacenter.

Scott Alan Miller
"import simplejson" works for me currently in 2.5
Jeremy Cantrell
@Jeremy: simplejson is not part of the Python 2.5 standard library, whereas the json module is new to the 2.6 standard library.
EOL
+4  A: 

The Multiprocessing module is cool. It has a Thread-like API for spawning and coordinating multiple OS processes:

http://docs.python.org/library/multiprocessing.html

You can sidestep the GIL with this in certain instances where multi-threaded code would be pegged to one processor or core at a time.

Corey Goldberg
+1  A: 

Multiprocessing isn't new. The module existed before being included in the standard library.

It all depends on the project. For my own personal projects, I will play around with the new features, basically because 2.6 is paving the way to 3.0. But most applications keep a compatibility with 2.4. I don't think there is something earth-shattering in 2.6 that I need to convert older projects into using new features.

ΤΖΩΤΖΙΟΥ
+3  A: 

The with statement is a very important addition to the language.

Now you can code something like:

with open('afile.txt') as thefile:
  do_something(thefile)

And at the end of the block, the file will be automatically closed.

And you can do a lot of things like (database connection for example)

Oli
'with' is not new in 2.6, it's just available without a __future__ import now.
Thomas Wouters
it's new in the sense that it's a reserved keyword in 2.6. this was not the case with the __future__ import.
Jeremy Cantrell
If you import with from __future__, it makes `with` a reserved word in the current file.
John Millikin
But python uses ref. counting (as well as GC), so "for line in open('afile.txt'):" will also close the file at the end of the for loop, unless you do very weird stuff.
James Antill
if an exception occurs in the for loop, the file won't be closed. If you use the with statement, it will.
Oli
A: 

Advanced string formating and the new print function (available in the __future__ module) are certainly going to help a lot.

Oli