我有一个想要迭代的boto3客户端方法列表,创建一个客户端,并为此做些事情。
例如
methods = ['allocate_address', 'allocate_address', 'attach_volume']
client = boto3.client('ec2')
for method in methods:
# below doesn't work
bound_method = client.method # <-- I want to use the variable to set this
我可以这样做吗?
答案 0 :(得分:0)
基于@ krishna_mee2004的评论,我能够使用以下方法做到这一点:
methods = ['allocate_address', 'allocate_address', 'attach_volume']
client = boto3.client('ec2')
for method in methods:
bound_method = getattr(client, method)