Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
functions in a dictionary
#4
Is this more like what you want?

function_dictionary = {'fun1':lambda a:a*a, 'fun2': lambda a:a+a}
print function_dictionary['fun1'](3) # prints 9
print function_dictionary['fun2'](7) # prints 14
Reply


Messages In This Thread
functions in a dictionary - by Skaperen - Apr-25-2019, 11:05 PM
RE: functions in a dictionary - by woooee - Apr-26-2019, 12:25 AM
RE: functions in a dictionary - by Skaperen - Apr-26-2019, 03:45 AM
RE: functions in a dictionary - by JohnKentzelGriffin - Apr-26-2019, 06:00 AM
RE: functions in a dictionary - by Skaperen - Apr-27-2019, 12:24 AM
RE: functions in a dictionary - by perfringo - Apr-26-2019, 06:21 AM
RE: functions in a dictionary - by DeaD_EyE - Apr-26-2019, 06:34 AM
RE: functions in a dictionary - by rxndy - Apr-27-2019, 02:25 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  functions and dictionary spalisetty06 3 1,908 Aug-22-2020, 04:50 PM
Last Post: jefsummers

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020