Skip to content
Better HN
Top
New
Best
Ask
Show
Jobs
Search
⌘K
Show HN: Switch-Case Construct in 3 Lines of Python | Better HN
Show HN: Switch-Case Construct in 3 Lines of Python
(opens in new tab)
(github.com)
3 points
ssanderson11235
10y ago
2 comments
Share
2 comments
default
newest
oldest
maaaats
10y ago
Oh, that's clever. Had to read it a couple times to see what was happening.
ssanderson11235
OP
10y ago
Heh, thanks. It's amazing how well-suited Python's for-loop is for emulating this behavior: `break` just does exactly what you want, and you can throw in an else-block where you'd use a default in another language.
j
/
k
navigate · click thread line to collapse