Question about inheritance in cssselect.py
![](https://secure.gravatar.com/avatar/9829fa44a1457eddda0902cfb9334d02.jpg?s=120&d=mm&r=g)
lxml v.4.9 cssselect.py:CSSSelector.__init__ calls on `etree.XPath.__init__(self, path, namespaces=namespaces)` to initialize the parent class. Is there a reason why `super()` or even `super(CSSSelector, self)__init__...` is not used? I bring this up as if I attempt to monkey patch (private project) `etree.XPath.__init__` the current code causes an error ``` TypeError: super(type, obj): obj must be an instance or subtype of type ``` while replacing it with the suggested use of `super()` fixes my error.
![](https://secure.gravatar.com/avatar/9829fa44a1457eddda0902cfb9334d02.jpg?s=120&d=mm&r=g)
![](https://secure.gravatar.com/avatar/06973596c04fdc676c6678af597dd755.jpg?s=120&d=mm&r=g)
I thought I was going nuts too, but this is why I kept on getting this error. Simply quitting and re-entering Python fixed it. https://slope-unblocked.co
![](https://secure.gravatar.com/avatar/8b97b5aad24c30e4a1357b38cc39aeaa.jpg?s=120&d=mm&r=g)
Dani Litovsky Alcala schrieb am 10.06.22 um 17:34:
lxml v.4.9
cssselect.py:CSSSelector.__init__ calls on `etree.XPath.__init__(self, path, namespaces=namespaces)` to initialize the parent class.
Is there a reason why `super()` or even `super(CSSSelector, self)__init__...` is not used?
Probably the age of the code.
I bring this up as if I attempt to monkey patch (private project) `etree.XPath.__init__` the current code causes an error ``` TypeError: super(type, obj): obj must be an instance or subtype of type ```
while replacing it with the suggested use of `super()` fixes my error.
I'll change it to use super(). Thanks for the suggestion. Stefan
participants (3)
-
Dani Litovsky Alcala
-
Stefan Behnel
-
veronicalarsen0793@gmail.com