I have 2 very similiar classes: A and B:
import attr
@attr.s
class A(object):
x = attr.ib()
y = attr.ib()
@attr.s
class B(object):
x = attr.ib()
z = attr.ib()
y = attr.ib(default=None)
As you can see, they share 2 attributes (x and y), but in class A y attribute is positional while in B it's optional.
I want to group these classes in one super class, but if I try making class B inherit from class A I get the following error:
SyntaxError: duplicate argument 'y' in function definition
Added the code I used for raising the error:
@attr.s
class A(object):
x = attr.ib()
y = attr.ib()
@attr.s
class B(A):
z = attr.ib()
y = attr.ib(default=None)
So my question is: is it possible group these classes in one super class using attrs module? if no, would you suggest me just grouping them like the 'old fashion' way instead (implementing init methods on my own)?
Many thanks!