You can avoid this with something like:
class C(object):
def __init__(self, x, y, z, etc):
self.__dict__.update(locals())
then all these arguments become members (including the self argument). Therefore, you can remove it with:self.__dict__.pop('self')
I don't know how pythonic this approach is, but it works.
PS: If you are interested in what it is __dict__, then this is a dict that contains each instance element in the form{'member1': value, 'member2': value}
locals() is a function that returns a dict with local variables.
source
share