The underscore is already a viable identifier:

>>> _ = lambda x:x*2
>>> _(3)


>>> x = lambda _:_*2
>>> x(3)

So I don't think you can use it the way you're proposing without breaking existing programs

On Fri, Aug 7, 2009 at 8:46 AM, ilya <> wrote:
I was thinking about a good syntax for implicit lambdas for a while
and today I had this idea: make ``_:`` a shortcut for ``lambda

For example:

   map( _: _ + 5, some_list)
   register_callback( _: True)
   def apply_transform(..., transform = _:_, ... ):

but still

   addition = lamba x, y: x + y

The rationale is that you only want to get rid of lambda keyword to
create a *very* simple function, the one that will be called either
without parameters or with only one parameter. For everything more
complicated, you really should go and write the explicit function
signature using lambda.

Even though ``:`` could theoretically denote implicit lambda, it's too
easy to miss it. The combination ``_:`` is much easier to notice. It
also makes explicit that there is at most one parameter and it's name
is ``_``. Since it's very short, it can easily be used in a long
function call or as a default parameter, as above

Your thoughts?
Python-ideas mailing list

Gerald Britton