One way is to create properties for each of them:
@property
def param_1(self):
return self.big_parameter_group.small_parameter_group.param_1
@property
def param_2(self):
return self.big_parameter_group.small_parameter_group.param_2
@property
def param_2(self):
return self.big_parameter_group.small_parameter_group.param_2
Another more robust but less explicit way would be to override the getattr method like so:
def __getattr__(self, name):
import re
p = re.compile('param_[0-9]+')
if p.match(name):
return getattr(self.big_parameter_group.small_parameter_group, name)
else:
return super(MyClass, self).__getattr__(name)
This will work for any property that matches the format specified by the regex (param_[some number])
Both of these methods will allow you to call self.param_1 etc, but it's just for retriving. If you want to set the attributes you'll need to also create a setter:
@param_1.setter
def param_1(self, value):
print 'called setter'
self.big_parameter_group.small_parameter_group.param_1 = value
Or to complement getattr:
def __setattr__(self, name, value):
import re
p = re.compile('param_[0-9]+')
if p.match(name):
return setattr(self.big_parameter_group.small_parameter_group, name, value)
else:
return super(MyClass, self).__setattr__(name, value)
(Haven't tested these out so there may be typos but the concept should work)