Brandt Bucher <brandtbuc...@gmail.com> added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42128>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to