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 s
Similar to the above, though not the same... the following is very short, deals with args and kwargs:
args
kwargs
def autoassign(lcls): for key in lcls.keys(): if key!="self": lcls["self"].__dict__[key]=lcls[key]
Use like this:
class Test(object): def __init__(self, a, b, *args, **kwargs): autoassign(locals())