LWN.net Logo

What's new in Python 2.6

What's new in Python 2.6

Posted Sep 3, 2008 11:43 UTC (Wed) by MiguelAtWork (guest, #53380)
In reply to: What's new in Python 2.6 by jamesh
Parent article: What's new in Python 2.6

I hadn't read PEP 8 before and I found it interesting, but it doesn't seem to help much with consistency in the use of underscores. New functions in 2.6 include such names as namedtuple, isgeneratorfunction or methodcaller on the no-underscores front, and ignore_patterns or create_connection on the other side. This still seems fairly random to me.

As for the comment about "next", I was thinking of code like this:

def old_function():
        global next
        next = "Hi!"

# ... 1000 lines of code here ...

def new_function(it):
        value = next(it)
I believe this would fail.


(Log in to post comments)

What's new in Python 2.6

Posted Sep 3, 2008 13:10 UTC (Wed) by amk (subscriber, #19) [Link]

Regarding the 'next' example: Yes, that code would crash, but that's not breaking *existing* code; you would have to add new code that used the next() built-in, and that would simply be a coding error. Existing applications that happen to use 'next' as a variable name should be OK.

What's new in Python 2.6

Posted Sep 3, 2008 16:16 UTC (Wed) by MiguelAtWork (guest, #53380) [Link]

I know, sorry I wasn't clear. The situation I was thinking of is one where you're updating an application written before 2.6 but you're unaware that the application redefines e.g. next. I don't think that's too far-fetched.

What's new in Python 2.6

Posted Sep 4, 2008 2:28 UTC (Thu) by jamesh (guest, #1159) [Link]

Assuming that the code has been broken up into reasonable sized modules, this isn't usually that big a deal. You can tackle the "Python 2.6 cleanness" problem on a module by module basis. A global next variable/function in one module isn't going to shadow the builtin in other modules.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds