How can I call super () so that it is compatible in 2 and 3?

I am trying to write 2/3 compatible code with six, but I do not see how I can call it in a super()cross-compatible way. Is there an even better way, for example:

class MyClass(MyBase):
    def __init__():
        if six.PY3:
            super().__init__()
        else:
            super(MyClass, self).__init__()
        ...
+4
source share
1 answer

Using super()with arguments is backward compatible, so you should just use super(MyClass, self)without checking the version.

+12
source

Source: https://habr.com/ru/post/1526841/


All Articles