Automate storing of Object given parameters at creation
28 janvier 2017 à 22:41
Basically replacing this
class A:
def __init__(self, b, c, d, e):
self.b = b
self.c = c
self.d = d
self.e = e
by
class A:
def __init__(self, b, c, d, e):
# You can edit parameters' value here before they are being stored
for k, v in vars().items():
setattr(self, k, v)
By me.
— Permalink
class A:
def __init__(self, b, c, d, e):
self.b = b
self.c = c
self.d = d
self.e = e
by
class A:
def __init__(self, b, c, d, e):
# You can edit parameters' value here before they are being stored
for k, v in vars().items():
setattr(self, k, v)
By me.
— Permalink