Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialEddy Hood
10,154 PointsHow is Super() meeting the DRY requirement? It seems to add more work.
I was all excited about inheritance until we got to super(). How is this saving us time and code if we have to now create two init methods in a subclass?
1 Answer
doesitmatter
12,885 PointsSure it would violate the DRY principle if we had to rewrite the entire __init__
of the super class, however we don't, we simply point to it, passing the arguments or kwargs it needs:
super().__init__(*args, **kwargs)
You shouldn't see the initialization of the super class as repeating yourself, instead look at it like setting the foundation on which your sub-class will be built.