On 5/3/2018 9:16 AM, Joao S. O. Bueno wrote:
(sorry - my aboe message is about using a dictionary - the "=>" weird
tokens should j=be just plain ":" -
the point is that Python açready has syntax to do what is asked)
On 3 May 2018 at 10:15, Joao S. O. Bueno <jsbu...@python.org.br> wrote:
What about instead of
number = match x:
1 => "one"
2 => "two"
3 => "three"
10 => "ten"
_ => "anything"
number = {
1 => "one"
2 => "two"
3 => "three"
10 => "ten"
}.get(x, "anything")
No magic syntax with blocks starting inside an assignment, just to start with.
This was my initial response until I read the further examples that
cannot be done with a dict.
--
Terry Jan Reedy
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/