Instead of writing code like this every time I define a class:
class Foo(object):
def __init__(self, a, b, c, d, e, f, g):
self.a = a
self.b = b
self.c = c
self.d = d
self.e = e
self.f = f
self.g = g
I could use this recipe for automatic attribute assignment.
class Foo(object):
@autoassign
def __init__(self, a, b, c, d, e, f, g):
pass
Two questions:
- Are there drawbacks or pitfalls associated with this shortcut?
- Is there a better way to achieve similar convenience?