def getStuff(x):
return 'stuff'+x
def getData(x):
return 'data'+x
thefunctions = []
thefunctions.append("getStuff")
thefunctions.append("getData")
for i in thefunctions:
print i('abc')
Is this possible? Thank you.
thefunctions = [ getStuff, getData ]
for f in thefunctions:
print f('shazam')
Once you've done a def
statement, you've associated a name with a function. Just use that name to refer to the function.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.