You, a coward: Python doesn't have a switch statement

Me, a modern-day Galileo:

@christianp This actually is pretty neat because if you leave out the default case, any input not listed as a case will raise an exception. Automatic bounds checking!


@invis yeah, after I tooted that I realised I should've made all the cases subclasses of a generic CaseException, then you can catch the default case and real exceptions separately.

... if you were doing this in real life, which you shouldn't

· · Web · 0 · 0 · 2
Sign in to participate in the conversation

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!