Settings

Theme

Show HN: Switch-Case Construct in 3 Lines of Python

github.com

3 points by ssanderson11235 10 years ago · 2 comments

Reader

maaaats 10 years ago

Oh, that's clever. Had to read it a couple times to see what was happening.

  • ssanderson11235OP 10 years 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.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection