I am a learner and just want to know the basic concept of super().
Here in the given code I want to know the difference between the two child classes:
class Base(object): def __init__(self): print "Base created" class ChildOne(Base): def __init__(self): Base.__init__(self) class ChildTwo(Base): def __init__(self): super(ChildTwo, self).__init__() ChildOne() ChildTwo()
@Shubham, You can avoid referring to base class explicitly using super(). Multiple-inheritance is not possible without using super().
Python also changed its syntax in version 3.0 , super()._init_() and super(ChildTwo, self)._init_() both perform the same function but the later is a bit nicer.
For more information regarding super() visit this link-https://rhettinger.wordpress.com/2011/05/26/super-considered-super/
In Python 3, we can call it like this:
class ChildB(Base): def __init__(self): super().__init__()
You can use the following video tutorials to clear all your doubts:-
Certification in Digital Marketing |
Certification in Big Data Analytics |
Certification in Cloud & Devops |
Certification in Full Stack Web Development
Big Data and Data Science Master’s Course |
Data Science Architect Master’s Program |
Cloud and DevOps Architect Master’s Course |
Artificial Intelligence Engineer Master’s Course |
Microsoft Azure Certification Master’s Training
Data Science Course Online |
Big Data Hadoop Certification Training |
Machine Learning Course Online |
Artificial Intelligence Course and Training |
Salesforce Certification Training: Administrator and App Builder |
Tableau Training and Certification Course |
Python Data Science Course & Training |
Ethical Hacking Course |
Business Analyst Course |
Courses in Cyber Security
© COPYRIGHT 2011-2021 INTELLIPAAT.COM. ALL RIGHTS RESERVED.
Download Salary Trends Now !
Learn how professionals like you got up to 100% Salary Hike.