I want to be able to set the instance variable name in a Python class based on an argument in __init__
. Is this possible? Below is what I've tried but that doesn't work.
class my_class:
def __init__(self, var_name):
self['var' + var_name] = var_name