python - Using string to call function -


from en import verb print verb.tenses() print verb.infinitive('argue')   ['infinitive', 'present participle', 'past plural', '2nd singular present', '2nd singular past', 'past', '3rd singular present', 'past participle', '1st singular present', '1st singular past', '3rd singular past', 'present plural']     argue 

using this.

i can't find method give tenses of verb. there 1 way call each function: replace space list using verb object. how can accomplish this?

the input: argue. output should be: arguing,argued,argue..

you can create list of names / parameters each name of tense. example:

tense_functions = {     'infinitive': ('infinitive', {}),     'present participle': ('present_participle', {}),     '1st singular present': ('present', {'person': 1}),     ... } tense in verb.tenses():     options = tense_functions[tense]     func = getattr(verb, options[0])     print(func('argue', **options[1])) 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -