Message387371
I understand. I would just like to see something that won't give new Python pattern-matching users (read: everybody) the very painful first impression that this is a switch. Can we rework it like:
match input().split():
case []:
print("Got nothing!")
case [first]:
print(f"Got one word: {first}")
case [first, last]:
print(f"Got two words: {first} and {last}")
case _:
print("Got more than two words!")
Or something? (Pardon the example, I don't write many tutorials...)
I've seen too many knee-jerk reactions over the past weeks along the lines of "the new switch feature can't handle named constants!". My hope is something like the above might provide a more accurate, informative intro. |
|
Date |
User |
Action |
Args |
2021-02-19 23:56:56 | brandtbucher | set | recipients:
+ brandtbucher, gvanrossum, willingc, Daniel Moisset, lys.nikolaou, pablogsal, BTaskaya, kj |
2021-02-19 23:56:56 | brandtbucher | set | messageid: <1613779016.07.0.650008104942.issue42128@roundup.psfhosted.org> |
2021-02-19 23:56:56 | brandtbucher | link | issue42128 messages |
2021-02-19 23:56:55 | brandtbucher | create | |
|