Re:What Is the Switch-Case Equivalent in Python?
by heavenlyblue on Thursday April 15, 2021 @04:25AM
(#26817625)
But you can't do that for pattern matching either.
Re:What Is the Switch-Case Equivalent in Python?
by dragonwriter on Sunday April 04, 2021 @04:58AM
(#26687917)
> it's only for specific classes, you cannot change the behavior of 1 == "one"
More clearly because builtins are protected from monkey-patching, you can’t change the behavior of == where both operands are builtins. “Only for specific classes” implies the scope of applicability is much narrower than it is.
1) it's "opt in" (you need to explicit implement the dunder method) and
2) it's only for specific classes, you cannot change the behavior of 1 == "one"