in Education by
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() Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
@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/

Related questions

0 votes
    I'm learning the Python programming language and I've come across something I don't fully understand. In a method ... know very much. Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    There are two codes, what are the difference between them: Using type import types if type(q) is types. ... ): do_something_else() Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    Is there any reason for a class declaration to inherit from an object? I just found some code that does this ... class code follows... Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    Can someone tell me a static method in python, I don't want to use initialize a class like this to call ... ClassName.StaticMethod ( ) Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    I think the slice notation are sort of powerful but I don't know much about it, So can anyone give me a ... Python's slice notation? Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    Can someone tell me how to find all the files in directory with .txt extension in Python? Select the correct answer from above options...
asked Jan 23, 2022 in Education by JackTerrance
0 votes
    How to upgrade all python packages in one go using pip? Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    Can someone please tell me the difference between a function decorated with @staticmethod and one with @classmethod? Select the correct answer from above options...
asked Jan 20, 2022 in Education by JackTerrance
0 votes
    I want to write a program which returns different values for different input,it can be easily done using switch ... some alternative? Select the correct answer from above options...
asked Jan 24, 2022 in Education by JackTerrance
0 votes
    How can I convert a str from uppercase, or half uppercase to lowercase? E.x. "Decimeter" to "decimeter" Select the correct answer from above options...
asked Jan 24, 2022 in Education by JackTerrance
0 votes
    How can I get the number of elements of a list? Ex- items = [] items.append("one") items.append("two") items.append("three") Select the correct answer from above options...
asked Jan 24, 2022 in Education by JackTerrance
0 votes
    I want to freeze the dos pop-up, I already tried raw-input as mentioned in my study material of Python 2.6 and ... (3**200) raw_input() Select the correct answer from above options...
asked Jan 23, 2022 in Education by JackTerrance
0 votes
    In a list with range(1,16) and I am trying to divide this list in some fixed numbe n . Let's assume n=7 ... uneven, How can I do that? Select the correct answer from above options...
asked Jan 23, 2022 in Education by JackTerrance
0 votes
    I want to use python to connect to a MySQL database, how can I do that? Select the correct answer from above options...
asked Jan 23, 2022 in Education by JackTerrance
0 votes
    I want to extract an extension from a filename in Python, How can I do that? Select the correct answer from above options...
asked Jan 23, 2022 in Education by JackTerrance
...