Blog Rizauddin
And He found you lost and guided [you]. [93:7]
Pages
Home
Python
LaTeX
Linux
Windows
Travelog
About
Showing posts with label
key
.
Show all posts
Showing posts with label
key
.
Show all posts
Thursday, May 21, 2009
How to store functions in a dictionary in Python
This example uses a dictionary to store functions.
To call the function, use the dictionary key.
>>> f = {'plus_all':sum, 'find_max':max}
>>> f['find_max'](1,4,5,3,2,6)
6
>>> f['plus_all'](range(10))
45
Older Posts
Home
Subscribe to:
Posts ( Atom )