3 ms·
The problem with python class definition is the need to write instance vars 3x: def __init__(self, foo) self.foo = foo There is an attrs package a
by mixmastamyk 9y ago
The problem with python class definition is the need to write instance vars 3x:
def __init__(self, foo)
self.foo = foo
There is an attrs package and new proposal (https://github.com/ericvsmith/dataclasses/blob/master/pep-xxxx.rst https://github.com/ericvsmith/dataclasses/blob/master/pep-xx...) to remedy that.
- joshmaker 9y agoYeah, I guess I normally don't deal with enough properties like that for it to be a big deal in my workflow. When it's come up I've generally done something like: class Foo: bar = 42 def __init__(self, **kwargs): self.__dict__.update(**kwargs) But I agree that's not a super robust solution