[Python-Dev] python-dev Summary for 10-16-2003 through
11-15-2003[draft]
Raymond Hettinger
python at rcn.com
Sun Nov 23 19:27:29 EST 2003
> If you ever wanted to have the power of list comprehensions but
without
> the overhead of generating the entire list you have Peter Norvig
> initially and then what seems like the rest of the world for generator
> expressions.
[possibly mangled sentence doesn't make sense]
> After the addition of the 'key' argument to list.sort(), people began
to
> clamor for list.sort() to return self. Guido refused to do give in,
so
> a compromise was reached. 'list' now has a class method named
'sorted'.
> Pass it a list and it will return a *copy* of that list sorted.
[Add]
What makes a class method so attractive is that the argument need not be
a list, any iterable will do. The return value *is* of course a list.
By returning a list instead of None, list.sorted() can be used as an
expression instead of a statement. This makes it possible to use it as
an argument in a function call or as the iterable in a for-loop::
# iterate over a dictionary sorted by key
for key, value in list.sorted(mydict.iteritems()):
> As an interim solution, itertools grew a new function: tee. It takes
in
> an iterable and returns two iterators which independently iterate over
> the iterable.
[replace] two
[with] two or more
> The point that operator.isMappingType is kind of broken came up. Both
> Alex and Raymond Hettinger would not mind seeing it disappear. No one
> objected. It is still in CVS at the moment, but I would not count on
it
> necessarily sticking around.
["It's not quite dead yet" ;-) Actually, there may be a way to
partially fix-it so that it won't be totally useless].
> There was a new built-in named reversed(), and all rejoiced.
[And much flogging of the person who proposed it]
> Straight from the function's doc string: "reverse iterator over values
> of the sequence". `PEP 322`_ has the relevant details on this toy.
[Replace] toy
[With] major technological innovation of the first order
[Or just] builtin.
> Sets now at blazing C speeds!
[Looks like a certain parroteer will soon by eating pie!]
Another fine summary.
Thanks for the good work.
Raymond
More information about the Python-Dev
mailing list