Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class foo:
- a = 0 #class variable
- def __init__(self):
- self.b = 0 #instance variable
- d = {'command1' : func1, 'command2': func2, 'command3' : func3}
- #then somewhere else use this list to dispatch
- #given a string `str`
- func = d[str]
- func() #call the function!
Add Comment
Please, Sign In to add comment