Closed gsnedders closed 4 years ago
I don't think of this as being a Python 2 vs Python 3 thing at all. You can use either in both versions, right? And the semantics of each doesn't differ between Python 2 and 3.
I don't think of this as being a Python 2 vs Python 3 thing at all.
Yeah, I guess it's more a Python 2.1 v. Python 2.2 thing (when super
was introduced) 🙃
You can use either in both versions, right?
Mostly. You can only use super
with new-style classes in Python 2.
And the semantics of each doesn't differ between Python 2 and 3.
Modulo the above, correct.
For context: I was looking at modernising some old code which I believe had been using old-style classes in Python 2 as at some point performance of old-style classes had been better (or at least significantly enough so for library-internal objects created in a hot loop), hence why that code wasn't using super
.
@gsnedders you should try out pyupgrade https://github.com/asottile/pyupgrade/issues/305
I think this is out of scope for modernize as Superclass.__init__(self)
works on py2 and py3
Almost certainly needs to be opt-in, though, given both remain valid and have different semantics