Terry Hancock wrote: > With list comprehensions and generators becoming so integral, I'm > not sure about "unpythonic". And a syntax just occured to me -- > what about this: > > [y*x for x,y] > > ? > > (that is: > > [<expression> for <argument list>] > > It's just like the beginning of a list comprehension or generator, but > without the iterator. That implies that one must be given, and > the result is therefore a callable object.
As others have mentioned, this looks too much like a list comprehension to be elegant, which also rules out () and {}... but I really do like the infix syntax. Perhaps using angle-brackets would be useful? These have no grouping-meaning in Python that I'm aware of. Example, <y*x for x,y> I'd also prefer using 'with' rather than 'for' as the keyword -- 'with' doesn't suggest iteration. I also suggest parenthization of the argument list, since that makes a zero-argument lambda not look weird. To replicate the examples from http://wiki.python.org/moin/AlternateLambdaSyntax 1 lambda a, b, c:f(a) + o(b) - o(c) <f(a) + o(b) - o(c) with (a, b, c)> 2 lambda x: x * x <x * x with (x)> 3 lambda : x <x with ()> 4 lambda *a, **k: x.bar(*a, **k) <x.bar(*a, **k) with (*a, **k)> 5 ((lambda x=x, a=a, k=k: x(*a, **k)) for x, a, k in funcs_and_args_list) (<x(*a,**k) with (x=x, a=a, k=k)> for x, a, k in funcs_and_args_list) -- http://mail.python.org/mailman/listinfo/python-list