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__()
...
Using super()
with arguments is backwards compatible, so you should just be able to use super(MyClass, self)
without needing to check the version.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句