<div dir="ltr">> <span style="font-family:arial,sans-serif;font-size:13px">Please admit that this is way, way prettier.</span><br style="font-family:arial,sans-serif;font-size:13px"><div><br></div><div>If it's just a matter of prettyness, why not just alias lambda as λ<div>
<br></div><div>Then we can have</div></div><div><br></div><div><span style="font-family:arial,sans-serif;font-size:13px">matrix.transform(</span>λ<span style="font-family:arial,sans-serif;font-size:13px"> x, y: (y, x))</span><br>
</div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">I think it looks way prettier than either one: it doesn't have the verbosity of the lambda version, and doesn't have the weird contextuality of the = version.</span></div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Feb 27, 2014 at 3:38 PM, Joshua Landau <span dir="ltr"><<a href="mailto:joshua@landau.ws" target="_blank">joshua@landau.ws</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On 27 February 2014 04:19, Steven D'Aprano <<a href="mailto:steve@pearwood.info">steve@pearwood.info</a>> wrote:<br>
> On Wed, Feb 26, 2014 at 11:44:51AM -0800, Andrew Barnert wrote:<br>
><br>
>> But it becomes more useful if you do anything else:<br>
>><br>
>> Button("Do it!", on_click() = fire_the_ducks(42))<br>
>><br>
>><br>
>> At first glance, I think this is nice,<br>
><br>
> At first glance, it looks like you are setting the on_click argument to<br>
> the result of fire_the_ducks(42). This proposed syntax is going to be<br>
> *really easy* for people to misinterpret when they see it in use. And<br>
> not just novices -- I think this will be syntax that just begs to be<br>
> misinterpreted when reading code, and misused when writing it.<br>
><br>
> I think that having special syntax for anonymous function only inside<br>
> function calls with keyword arguments is a violation of the Zen of<br>
> Python (see the one about special cases) and the Principle Of Least<br>
> Surprise. It's really a bad idea to have syntax for a "shorter lambda"<br>
> that works here:<br>
><br>
> f(arg=***whatever***)<br>
><br>
> but not in these:<br>
><br>
> f(***whatever***)<br>
> [len, zip, map, ***whatever***, some_function]<br>
> result = ***whatever***(arg)<br>
<br>
</div>I don't follow. I know it's different, but we have<br>
<br>
f(*args) but not [*args]<br>
<br>
And we have<br>
<br>
start, *mid, end = [1, 2, 3] but not (lambda start, *mid, end: ...)(1, 2, 3)<br>
<br>
and we have<br>
<br>
(lambda x: ...)(*[...]) but not foo = *[...]<br>
<br>
... *wink¹*<br>
<br>
It's not silly to think that things are context-sensitive in a<br>
context-sensitive language. Personally this proposal makes sense and I<br>
honestly don't see the confusion that's being stated. It makes things<br>
significantly prettier and more readable, for one.<br>
<br>
Further, for consistency one can define:<br>
<br>
matrix.transform((x, y)=(y, x))<br>
<br>
as an "anonymous" version, compiling to<br>
<br>
matrix.transform(lambda x, y: (y, x))<br>
<br>
Please admit that this is way, way prettier.<br>
<br>
PS: One problem. "f( (a) = ... )" is currently valid. So is "f(<br>
(((((a))))) = ... )". Why the hell is this so? "(a) = 2" is valid, but<br>
so is "(a, b) = (2, 3)", whereas "f( (a, b) = (2, 3) )" is not.<br>
<br>
¹<a href="http://www.python.org/dev/peps/pep-0448/" target="_blank">http://www.python.org/dev/peps/pep-0448/</a><br>
<div class="HOEnZb"><div class="h5">_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank">http://python.org/psf/codeofconduct/</a></div></div></blockquote></div><br></div>