[ACCEPTED]-In python, super() is always called first in a method. Are there situations where it should be called later?-super
Accepted answer
Sometimes you need to validate the arguments 4 before calling super()
:
class UpperBase(Base):
def __init__(self, name):
if not name_valid(name):
raise ValueError()
super(UpperBase, self).__init__(name)
I don't see why this wouldn't 3 be pythonic, because it's the easiest way 2 to do it and it's straightforward. Also, read 1 @JHSaunders' comment, he makes a good point.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.