Yeah, the following should work:
from torchvision import models
m = 'vgg16'
my_model = getattr(models, m)(pretrained=True)
print(my_model)

the issue with your version was, that vgg16 actually is a function-name and yours is a string, so, what you were trying to do is something like models.'vgg16' and getattr resolves the function’s name.