Hi Abe

First, I have reservations about the name lambda. But there's a lot of
code out there that uses lambda, and I'd like that code to continue to
run.

You wrote:
> func = value[card.suit] if card not in wilds else wild_value with card

I thought I'd try this, and variants, in the Python interpreter. I got

# An expression. It's valid syntax, get run-time error.
>>> value[card.suit] if card not in wilds else wild_value
NameError: name 'card' is not defined

# An expression. It's valid syntax. Its value is a function. No run-time error.
>>> lambda card: value[card.suit] if card not in wilds else wild_value
<function <lambda> at 0x7ff815e2bbf8>

# If Python were enhanced, an valid expression whose value is a function.
>>> value[card.suit] if card not in wilds else wild_value with card
SyntaxError: invalid syntax

My understanding is that you prefer
>>> EXPRESSION with IDEN
to
>>> lambda IDEN: EXPRESSION

How do you feel about this, as a means of defining an anonymous function?
>>> with IDEN: EXPRESSION

We can't adopt it, of course, because it's already valid syntax, but
with semantics.

>>> with wibble:
...    wobble
NameError: name 'wibble' is not defined

Now for a trick question. Consider
>>> fn =  (lambda : EXPRESSION)
This produces a function that has zero parameters.

How would you write this, using 'with'. Would it be:
>>> fn = (EXPRESSION with)
I think this looks rather odd.

-- 
Jonathan
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to