Whenever I’m defining a class which has a number of parameters I often find myself doing something like this
class myClass(object):
def __init__(self,param1,param2,param3, ...):
self.param1 = param1
self.param2 = param2
self.param3 = param3
...
My question is: is there a smarter, Pythonier way of doing this?
Thanks,
Alex.
You could accept a variable number of named arguments and automatically set them, like this:
setattr documentation