[Python-3000] Requiring () around lambda's argument list

Guido van Rossum guido at python.org
Mon May 1 23:33:56 CEST 2006


Yes, they will always be needed, except perhaps for an empty parameter
list; you may be able to write lambda: blah instead of lambda(): blah.

--Guido

On 5/1/06, Raymond Hettinger <rhettinger at ewtllc.com> wrote:
> Guido van Rossum wrote:
>
> >I'm running into something that may make me require parentheses around
> >lambda's argument list.
> >
>
> Are the parens always needed or will it depend on the surrounding
> tokens?  Adding extra parens feels a bit odd in the following situations:
>
>     databases = filter(lambda name: name.startswith('2006'),
> cursor.fetchall())
>     mylist.sort(key = lambda record:  record.name.lower())
>
>
> Raymond
>
>


--
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list