Re: [Python-Dev] Shorthand for lambda

2005-03-24 Thread Hye-Shik Chang
On Wed, 23 Mar 2005 10:33:53 -0600 (CST), Ka-Ping Yee <[EMAIL PROTECTED]> wrote: > Hey folks, > > >>> 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,

Re: [Python-Dev] Shorthand for lambda

2005-03-23 Thread Josiah Carlson
Ka-Ping Yee <[EMAIL PROTECTED]> wrote: > > On Wed, 23 Mar 2005, Josiah Carlson wrote: > > Paul Moore <[EMAIL PROTECTED]> wrote: > > > 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 everythin

Re: [Python-Dev] Shorthand for lambda

2005-03-23 Thread Ka-Ping Yee
On Wed, 23 Mar 2005, Josiah Carlson wrote: > Paul Moore <[EMAIL PROTECTED]> wrote: > > 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 s

Re: [Python-Dev] Shorthand for lambda

2005-03-23 Thread Josiah Carlson
Paul Moore <[EMAIL PROTECTED]> wrote: > > On Wed, 23 Mar 2005 10:33:53 -0600 (CST), Ka-Ping Yee > <[EMAIL PROTECTED]> 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: > > > >

Re: [Python-Dev] Shorthand for lambda

2005-03-23 Thread Paul Moore
On Wed, 23 Mar 2005 10:33:53 -0600 (CST), Ka-Ping Yee <[EMAIL PROTECTED]> 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

Re: [Python-Dev] Shorthand for lambda

2005-03-23 Thread Jeremy Hylton
For filter and map, list comprehensions and generator expressions are the answer. >>> numbers = [5, 9, 56, 34, 1, 24, 37, 89] >>> [x for x in numbers if x < 30] [5, 9, 1, 24] >>> (x for x in numbers if x < 30) >>> list(_) [5, 9, 1, 24] Jeremy On Wed, 23 Mar 2005 10:33:53 -0600 (CST), Ka-Ping Ye

[Python-Dev] Shorthand for lambda

2005-03-23 Thread Ka-Ping Yee
Hey folks, I'm sitting over here in the AppleScript talk and Jacob is explaining a module called 'appscript' that interfaces to the Apple Events system. What caught my eye was this example: from appscript import * ab = app('Address Book') people = ab.people.filter(its.emails != [])