How to set a variable as an attribute?
I'm getting error when trying to set variable as an atribute. 

parser = argparse.ArgumentParser()

parser.add_argument('--arch', action='store',
                dest='arch', default='alexnet',
                help='Store a simple value') 

args = parser.parse_args()

model = models.args.arch(pretrained=True)


I know models.args.arch prodocues an error but how syntax should looke like to set a variable as an attribute? I could do it with if statements but it would be lot's of code and I guess it's possible in 1 line. 

You want to access the internal dict to update:

model = models.__dict__[args.arch](pretrained=True)


or using getattr:

 getattr(models, args.arch)(pretrained=True)

