[Python-Dev] Re: "groupby" iterator

Robert Brewer fumanchu at amor.org
Fri Dec 5 12:33:08 EST 2003

I wrote:
> > Why have the programmer bind a custom name to an object 
> we're going to
> > then use 'anonymously' anyway? I understand its historical 
> necessity,
> > but it's always struck me as more complex than the concept being
> > implemented. Ideally, we should be able to reference the passed-in
> > objects without having to invent names for them.

And Guido van Rossum answered:
> Huh?  How can you reference something without having a name for it?
> Are you proposing to add pronouns to Python?

That's one way of looking at it. In a sense, names are already personal
pronouns with mutable referents. I'm thinking about a language (and
maybe Python wouldn't be a good candidate) where it also has standard
impersonal pronouns like "it" and "they" in English. But in an
already-restricted context, that is, lambda.

> There are lots of situations where the comparison lambda is just a bit
> more complex than this, for example:
>   lambda x, y: cmp(x[0], y[0]) or cmp(x[1], y[1])
> And how would you spell lambda x, y: x+y?  "+ using item"???  That
> becomes a syntactical nightmare.  (Or what about lambda x, y: 
> 2*(x+y)?)

Good questions.

> I've read this whole post twice, and I still don't understand what
> you're really proposing (or how it could ever work given the rest of
> Python), so I think it's probably not a good idea from a readability
> perspective...

That's fine. I'm really just musing; I'll refrain from that in the
future on this list unless I have code. ;) I work far too intuitively
sometimes. Maybe in the Spring, when I'll have time to dig into
internals and form a sample implementation. Thanks for your comments.

I *do* think this thread needs to get back to, "are we going to have
'groupby' in 2.4 or later?"

Robert Brewer
Amor Ministries
fumanchu at amor.org

More information about the Python-Dev mailing list