Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Python: create a simple switch statement

Python:  create a simple switch statement

def show(s):
    print s
def switch(ch):
      {'1': lambda : show("January"),
       '2': lambda : show("February"),
       '3': lambda : show("March"),
       'show': lambda : show("My Name")
    except KeyError:
      show("Key not Found")
switch('1')           # January
switch('show')        # MyName
switch('b')           # Key not Found

Users who found this page were searching for:

  • python: convert serial-read string to number
  • python create text file
  • how to close a file python
  • python key event
  • python what is the focus widget
  • python if is pressed
  • message dialog, python
  • perl iterate through linked list
  • iterate over dictionary python

No comments yet.

Leave a Comment