The meaning of `this`

https://lemmy.world/post/31027668

Partially unrelated to the meme, but I find it almost malicious how some python keywords are named differently from the nearly universal counterpart of other languagues.

This/self, continue/pass, except/catch and they couldn’t find a different word for switch so they just didn’t implement it.

It’s as if the original designers purposefully wanted to be different for the sake of it.

Python does have a switch statement now, actually. And yes, they went out of their way to call it something different - match.

docs.python.org/3/tutorial/controlflow.html#match…

4. More Control Flow Tools

As well as the while statement just introduced, Python uses a few more that we will encounter in this chapter. if Statements: Perhaps the most well-known statement type is the if statement. For exa...

Python documentation
match isn’t just equivalent to switch though, so in this case it actually makes sense to call it something different.

This is very true. Match statements are much more powerful that switch statements in any other language.

For instance:

  • matching objects very specifically
  • if conditions within case statements
  • pulling variables from inside of the object directly.