On 16/07/2020 19:00, Rhodri James wrote:
On 16/07/2020 17:37, Steve Holden wrote:
While I understand the point of view that says that match ... :
should encapsulate a sequence of indented suites, it seems to me that
match/case/case/.../else has a natural affinity with
try/except/except/.../finally/else, and nobody seems to think that the
excepts should be indented. Or the finally. And naturally the match/else
case are at the same indentation level, just as for/else, while/else and
try/finally. So why, exactly, should case be indented?
[...]
If we did:

    match:
        <expression>
    case <pattern>:
        <suite>


then having an indented section which must be a single expression would be unique in Python syntax.

[...]

    match <expression>:
    case <pattern>:
        <suite>


would be the one place in Python where you end a line with a colon and *don't* indent the following line.

It seems relevant to mention that before Python's unique syntax for a ternary operator (x = something if something else default_value), you would never find an if or else without a colon and an indented block, and the order (value, condition, default) is different than what is usually found in other languages (condition, value, default). That hasn't stopped Python from implementing the feature in its own way and I don't see why this PEP should be different, since Python is not other languages and match suites are not other suites.

I could easily see people being confused when the slew of statements they would inevitably decide they must be able to put there, and soon we'd have cats and dogs living together and the downfall of civilisation as we know it.
[...]
Writers of simple formatters and the like (such as Python-mode in Emacs) would curse your name, etc, etc.
Tools should adapt to the language, not the other way around. If things had to be done the way they had always been done, without any change, for fear of people not being used to it, we wouldn't even have Python at all. People learn and adapt. It seems like a small price to pay in exchange for consistency and removal of ambiguity, considering people will still have to learn the new feature one way or another.