Thursday, 15 January 2015

python - How to make a 'str' object callable using lambda functions? -



python - How to make a 'str' object callable using lambda functions? -

i have predefined functions me, : addhost, edithost, deletehost.

now based on param received, have phone call 1 of above functions. value of param same 1 of above functions.the type of param str.

for example: if param 'addhost', should able phone call addhost(). when directly, gives me error 'str' object not callable how should phone call appropriate function based on param received ??

p.s. dont want utilize conditionals, want go lambda functions.

i lean towards getattr method described here: http://stackoverflow.com/a/3071/3757019

python string lambda

No comments:

Post a Comment