Using super()
with arguments is backwards compatible, so you should just be able to use super(MyClass, self)
without needing to check the version.
How can I call super() so it's compatible in 2 and 3?
-
11-10-2022 - |
Question
I'm trying to write 2/3 compatible code using six
, but I don't see how I can call super()
in a cross-compatible manner. Is there some better way besides, for example:
class MyClass(MyBase):
def __init__():
if six.PY3:
super().__init__()
else:
super(MyClass, self).__init__()
...
La solution
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow