4 May
2018
4 May
'18
3:20 a.m.
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
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