Re: Special keyword argument lambda syntax

2009-03-14 Thread Rhodri James
On Fri, 13 Mar 2009 15:33:26 -, MRAB wrote: Rhodri James wrote: On Fri, 13 Mar 2009 14:49:17 -, Beni Cherniavsky wrote: Specification = Allow keyword arguments in function call to take this form: NAME ( ARGUMENTS ) = EXPRESSION which is equivallent to the foll

Re: Special keyword argument lambda syntax

2009-03-14 Thread Rhodri James
On Fri, 13 Mar 2009 16:39:16 -, Scott David Daniels wrote: The original proposal was initially appealing to me until I saw this comment. That means a relatively "invisible typo" would turn into good syntax. Possibley this is exactly what Rhodri James is talking about, but just to be exp

Re: Special keyword argument lambda syntax

2009-03-14 Thread Beni Cherniavsky
On Mar 14, 5:30 pm, Nick Craig-Wood wrote: > BeniCherniavsky wrote: > >  This proposal outrageously suggests a special syntax for in-line > >  functions passed as keyword arguments:: > > >      >>> sorted(range(9), key(n)=n%3) > >      [0, 3, 6, 1, 4, 7, 2, 5, 8] > > >  The claim is that such spec

Re: Special keyword argument lambda syntax

2009-03-14 Thread Nick Craig-Wood
Beni Cherniavsky wrote: > This proposal outrageously suggests a special syntax for in-line > functions passed as keyword arguments:: > > >>> sorted(range(9), key(n)=n%3) > [0, 3, 6, 1, 4, 7, 2, 5, 8] > > The claim is that such specialization hits a syntax sweet spot, and > that thi

Re: Special keyword argument lambda syntax

2009-03-13 Thread bearophileHUGS
MRAB: >  >>> sorted(range(9), def key(n): n % 3) I am fine with the current lambda syntax, but another possibility: sorted(range(9), n => n % 3) Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: Special keyword argument lambda syntax

2009-03-13 Thread MRAB
Hrvoje Niksic wrote: MRAB writes: sorted(range(9), def key(n): n % 3) [0, 3, 6, 1, 4, 7, 2, 5, 8] Given the recent pattern of syntactic constructs for expressions using (ternary if, listcomps, genexps), and avoiding the use of colon in expressions, maybe it should be: sorted(range(9), k

Re: Special keyword argument lambda syntax

2009-03-13 Thread Hrvoje Niksic
MRAB writes: sorted(range(9), def key(n): n % 3) > [0, 3, 6, 1, 4, 7, 2, 5, 8] Given the recent pattern of syntactic constructs for expressions using (ternary if, listcomps, genexps), and avoiding the use of colon in expressions, maybe it should be: sorted(range(9), key=n % 3 def key(n)

Re: Special keyword argument lambda syntax

2009-03-13 Thread Scott David Daniels
Rhodri James wrote: On Fri, 13 Mar 2009 14:49:17 -, Beni Cherniavsky wrote: ...Allow keyword arguments in function call to take this form: NAME ( ARGUMENTS ) = EXPRESSION which is equivallent to the following: NAME = lambda ARGUMENTS: EXPRESSION except that NAME is also assigned as

Re: Special keyword argument lambda syntax

2009-03-13 Thread MRAB
Rhodri James wrote: On Fri, 13 Mar 2009 14:49:17 -, Beni Cherniavsky wrote: Specification = Allow keyword arguments in function call to take this form: NAME ( ARGUMENTS ) = EXPRESSION which is equivallent to the following: NAME = lambda ARGUMENTS: EXPRESSION exce

Re: Special keyword argument lambda syntax

2009-03-13 Thread Rhodri James
On Fri, 13 Mar 2009 14:49:17 -, Beni Cherniavsky wrote: Specification = Allow keyword arguments in function call to take this form: NAME ( ARGUMENTS ) = EXPRESSION which is equivallent to the following: NAME = lambda ARGUMENTS: EXPRESSION except that NAME is also

Special keyword argument lambda syntax

2009-03-13 Thread Beni Cherniavsky
This proposal (a) ignores Guido's clear-cut decision that lambda is good as it is, (b) is weird in proposing a special-case syntax, (c) is several Python versions too late for a graceful transition by 3.0. But I don't won't to just throw the idea away, so I'm posting here. If there is serious posit