The underscore is already a viable identifier:<div><br></div><div><div>>>> _ = lambda x:x*2</div><div><div>>>> _(3)</div><div>6</div><div><br></div><div>and</div><div><br></div><div><div>>>> x = lambda _:_*2</div>

<div>>>> x(3)</div><div>6</div><div>>>> </div><div><br></div><div><br></div></div><div>So I don't think you can use it the way you're proposing without breaking existing programs</div></div><div>

<br></div><br><div class="gmail_quote">On Fri, Aug 7, 2009 at 8:46 AM, ilya <span dir="ltr"><<a href="mailto:ilya.nikokoshev@gmail.com">ilya.nikokoshev@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

I was thinking about a good syntax for implicit lambdas for a while<br>
and today I had this idea: make ``_:`` a shortcut for ``lambda<br>
_=None:``<br>
<br>
For example:<br>
<br>
    map( _: _ + 5, some_list)<br>
    register_callback( _: True)<br>
    def apply_transform(..., transform = _:_, ... ):<br>
<br>
but still<br>
<br>
    addition = lamba x, y: x + y<br>
<br>
The rationale is that you only want to get rid of lambda keyword to<br>
create a *very* simple function, the one that will be called either<br>
without parameters or with only one parameter. For everything more<br>
complicated, you really should go and write the explicit function<br>
signature using lambda.<br>
<br>
Even though ``:`` could theoretically denote implicit lambda, it's too<br>
easy to miss it. The combination ``_:`` is much easier to notice. It<br>
also makes explicit that there is at most one parameter and it's name<br>
is ``_``. Since it's very short, it can easily be used in a long<br>
function call or as a default parameter, as above<br>
<br>
Your thoughts?<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-ideas" target="_blank">http://mail.python.org/mailman/listinfo/python-ideas</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Gerald Britton<br>
</div>