[Python-Dev] Shorthand for lambda
Josiah Carlson
jcarlson at uci.edu
Wed Mar 23 18:48:08 CET 2005
Paul Moore <p.f.moore at gmail.com> wrote:
>
> On Wed, 23 Mar 2005 10:33:53 -0600 (CST), Ka-Ping Yee
> <python-dev at zesty.ca> wrote:
> > It dawned on me that you could use this idea to make the whole
> > filter/lambda experience vastly more pleasant. I whipped up a quick
> > implementation:
> >
> > >>> from placeholder import _
> > >>> numbers = [5, 9, 56, 34, 1, 24, 37, 89]
> > >>> filter(_ < 30, numbers)
> > [5, 9, 1, 24]
> > >>> map(_ + 10, numbers)
> > [15, 19, 66, 44, 11, 34, 47, 99]
> > >>>
> >
> > Look ma, no lambdas!
> >
> > I bet someone has already done this before, right?
>
> I thought about it, but couldn't convince myself that it would work
> properly in all cases. I was thinking in terms of operator overloading
> of everything possible - how did you do it?
PyTables allows something very similar for "in-kernel" searches of data,
but only on a single constraint. I would imagine that Ka-Ping did it by
only allowing a single operation per item.
- Josiah
More information about the Python-Dev
mailing list