On 11/07/20 11:20 pm, Paul Sokolovsky wrote:
On Sat, 11 Jul 2020 22:49:09 +1200
Greg Ewing <greg.ew...@canterbury.ac.nz> wrote:

or like this:

     switch (x) {
     case 1:
        ...
     case 2:
        ...
     default:
        ...
     }

Oh really, you never saw that? Well, they say that any programmer
should eyeball the source code of the most popular open-source OS at
least once:
https://elixir.bootlin.com/linux/latest/source/kernel/sys.c#L2144

I stand corrected -- it seems I haven't looked at other people's
switch statements all that much.

I can see that being a reasonable choice if you're using 8-space
indents, but I don't see that done much in Python.

Also, directly translating this into Python leads to something that
looks like a mistake:

    match x:
    case 1:
        ...
    case 2:
        ...

and as has been pointed out, the alternative of putting x on the
next line is unprecedented in Python.

--
Greg
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/QWSYAU3WIXHG2TYKMGJTARDJ2Z7A7YN4/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to