PDA

View Full Version : New in Python 2.2


Strike
06-19-2002, 12:13 PM
Yeah, I know Python 2.2 has been out for a while now, but I found a neat slide show by Guido demonstrating the new stuff and the motivations behind them:

http://www.python.org/doc/essays/ppt/lwnyc2002/whatsnew22.pdf

(PDF format)

One of the neat things I liked was the unification of longs and plain ints, though it's still clear that there once was a distinction (i.e., things that are returned as results that are bigger than sys.maxint all have L's appended onto the end)

Strike
06-19-2002, 12:29 PM
Another interesting bit of change. Here's a way of using iterators to read lines from a file until you reach a certain line:


myfile = file('somefile', 'r')
myiter = iter(myfile.readline, 'foo') # want to stop once we hit 'foo' in the file
for line in myiter:
print line

jemfinch
06-20-2002, 09:31 PM
Originally posted by Strike
One of the neat things I liked was the unification of longs and plain ints, though it's still clear that there once was a distinction (i.e., things that are returned as results that are bigger than sys.maxint all have L's appended onto the end)

I very much dislike this. I think it's a poor design decision for a language to automatically switch between bounded computation (i.e., calculations with integers of fixed maximum size) and unbounded computation (calculations with arbitrary sized integers.) It makes things much harder for the programmer in cases where he wants to be assured that computation based on arbitrary user input is a bounded computation.

Jeremy

Strike
06-20-2002, 10:36 PM
Well, perhaps you should submit a PEP that suggests a way of enforcing that :)