The Null Device

switch() in Python

Nifty Python hack of the day: a C-style switch() construct, implemented without using dictionaries (instead using a class and yield).

There are no comments yet on "switch() in Python"

Want to say something? Do so here.

Post pseudonymously

Display name:
To prove that you are not a bot, please enter the text in the image into the field below it.

Your Comment:

Please keep comments on topic and to the point. Inappropriate comments may be deleted.

Note that markup is stripped from comments; URLs will be automatically converted into links.