|
|
Subscribe / Log in / New account

A more generalized switch statement for Python?

A more generalized switch statement for Python?

Posted Jul 9, 2016 4:28 UTC (Sat) by marcH (subscriber, #57642)
In reply to: A more generalized switch statement for Python? by gasche
Parent article: A more generalized switch statement for Python?

Once you've seen in action ML-like pattern matching in some random language (from the ML family or not) and caught actual bugs thanks to it, then people claiming that if/elif/else is "The One Obvious Way to Do It" really sound like they're from the distant past. Maybe still trying to do large-scale development in assembly or something.

Quite surprising from Python: an otherwise fairly high-level language.


to post comments

A more generalized switch statement for Python?

Posted Jul 10, 2016 18:19 UTC (Sun) by HIGHGuY (subscriber, #62277) [Link] (1 responses)

Pattern matching in those languages is great... because of the very strong typing (and automatic type deduction).
Putting this kind of matching with python's duck-typing is like trying to have your cake and eat it too. It's just going to cause even more subtle bugs that are hard to diagnose or find.

A more generalized switch statement for Python?

Posted Jul 10, 2016 20:14 UTC (Sun) by flussence (guest, #85566) [Link]

The very least they could do here is learn to not repeat the mistakes Perl 5 did in trying to add a switch construct to the language.

The examples given all look very *pretty*, which is what one would expect Python culture to focus on, but they're harder to *understand*.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds