[Python-Dev] Re: "groupby" iterator
ncoghlan at iinet.net.au
Wed Dec 3 06:48:49 EST 2003
Raymond Hettinger wrote:
> Carried to the limit, the idea turns into something that is
> either sublime or severely bonkers. The good points are that
> Guido gets his dotted access and I get to trade in the two ugly
> names and for a single beautiful "extract". And there's no performance
> cost, the inner loop is the same. The downside is I still don't
> know how to explain it (AFAICT, super() is the closest thing to it):
What you end up with is still a unary operator, so it could still live
in the operator module, to.
And I think what you posted would work for strings as dictionary keys,
too - answering another of the objections to the original operator.extract
Which leaves figuring out a concise explanation for what the hell it
does (without using lambda in the examples, since I assume part of the
aim here is to avoid explaining lambda to people who don't need it). . .
"operator.extract provides an interim target for an attribute or item
access where the real target of the access is to be determined later.
The access is made normally (i.e. dotted notation or indexing), with
'operator.extract' substituted where the target would normally be
written. The actual access is carried out by calling the result returned
by the expression operator.extract is part of with the real target as
the first argument.
y = operator.extract.foo
is equivalent to
y = operator.extract
is equivalent to
If you meant a concise explanation of _how_ it does what it does, then
I'm not sure that can be done :)
And I still don't know if I should be admiring this or running away
More information about the Python-Dev