Python's method of calling the parent class can be implemented in two ways: by calling the parent class construction method, or by using the Super function (do not mix them).The Code "super (Foochild,self). __init__ (xxx,xxx)" often appears when using "super". So how does super () __init__ () really work?To facilitate
------------- - Zpoor in 0 the Mans the - About the the the */Don't Panic (cool analysis):One, call another construction method through this, the This (argument list), only in the constructor, not elsewhere, and to be placed in the first row of the construction methodIn the case of the parameter of the method or the name of the local variable and member variable in the method, the member variable is masked and the member variable is referenced by the this. Member variable. If you don't have
The Super 3GP Converter is a powerful and easy-to-use 3GP video conversion software that converts almost all audio and video formats to the 3GP format supported by mobile phones. With super 3GP converters and no computers, you can watch movies and videos in all formats on your phone anytime, anywhere!
1, first download and install the Super 3GP Converter
2, dou
When initializing a subclass, the constructor of the parent class must run
Because there is an implicit statement super () in the first row of the constructor of the subclass, all constructors of the subclass default to the first row of super ();
Subclass calls the parent class constructor Super (parameter), the subclass calls the parent class general method:
Super key: An attribute set that uniquely identifies a tuple in a relationship is called a hyper-key of a relational patternCandidate key (candidate Key): A super-key that does not contain extra attributes is called a candidate keyPrimary key (primary key): A candidate key program primary key that the user selected as a tuple identityFor example, a small range of people, without the same name, consider the
The ability to implement super () and __init__ () is similar for single-inheritance
Class Base (object):d EF __init__ (self):p rint ' base create ' class Childa (base):d EF __init__ (self):p rint ' creat A ', base.__ Init__ (Self) class childb (base):d the EF __init__ (self):p rint ' creat B ', super (childb, self). __init__ () base = Base () A = Childa () b = childb ()
Output Result:
Base Createcreat A B
For example, classChild (Parent): def _ init _ (self): Parent. _ init _ (self), for example
class Child(Parent): def __init__(self): Parent.__init__(self) Reply content: the answer to your question is yes, and there is no difference. However, I don't feel good enough to answer this question.
To talk about super, we should first ignore the interference brought by the name "super.
Do not t
The difference between super () and _ init _ () in python classes is that python _ init __
The functions implemented by super () and _ init _ () for single inheritance are similar.
class Base(object):def __init__(self):print 'Base create'class childA(Base):def __init__(self):print 'creat A ',Base.__init__(self)class childB(Base):def __init__(self):print 'creat B ',super
this:First, call another constructor using this (parameter list). This is only used in the constructor of the class and cannot be used in other places.2. When the name of a function parameter or local variable in the function is the same as that of a member variable, the member variable is blocked. To access the member variable, you must use "this. to reference member variables. Of course, without the same name, you can directly use the name of the member variable instead of this. If you use th
Original address: https://www.cnblogs.com/hasse/p/5023392.htmlThese days to see the class in the inheritance will use this and super, here do a little summary, with you to communicate, there are errors please correct me ~ThisThis is an object of its own, representing the object itself, which can be understood as: A pointer to the object itself.The usage of this can be broadly divided into 3 types in Java:1. Normal Direct referencesThis does not have
The article turns from
@implementation Son:father
-(ID) init{
self = [super init];
if (self) {
} return
self;
}
This is an ordinary to initialization method that invokes the Init implementation of the parent class before the subclass implements initialization. Based on this initialization method, we compare the self and Super keywords from three aspects. what self is and what
Absrtact: In Java We will often use super and this usage, now I mainly to distinguish between super. And this and Superl () and this () the difference between them to know and understand:The usage of 1.this is in Java:①:this.:this refers to the current object, which can manipulate all the properties and methods inside the current class and the properties and methods that the parent inherits to allow access
Many users encounter the same problem in the super capacitor, that is, how to calculate the discharge time of a certain capacity super capacitor when a certain current is discharged, or according to the discharge current and discharge time, how to choose the capacity of the super capacitor, the following is a simple computing company. Based on this formula, you c
Enable super administrator privilege in Windows 7)(08:01:40)
Use a superuser to log on to Windows 7
Login to Windows 7 with a Super User is the same as that of Vista. After the system is installed, a user is created and the Administrator permission is used, while the Administrator is disabled. In most optimized systems, the Administrator is used to log in directly. Although it is administrator permissio
Time limit:20 Sec Memory limit:552 MBsubmit:2435 solved:1195DescriptionSmall Z is a small famous pianist, recently Dr. C gave a small z a super piano, small z hope to use this piano to create the world's most beautiful music. The super piano can play n notes, numbered 1 to N. The magic of the I note is AI, where AI can be negative. A "super chord" consists of a n
open closed-loop ecosystem, the introduction of eco-TV-4th generation Super TV X50 Pro (Ultra 4 X50 Pro), priced 2999 yuan, Ultra 4 X50, pricing 2499 yuan, Super 4 X50 in the Super version, pricing 2699 Yuan. These three products can be lower than the production cost pricing, through the eco-subsidized hardware, leading the television industry into the hardware
First, super keyword use super in the Java class to refer to the composition of the parent class, use this to refer to the current object , and if a class inherits from another class, when we new the instance object of the subclass, there will be a parent class object inside the subclass object. How do you refer to the parent object inside? Using Super to refer
This article mainly introduces the usage examples of super in Python, this article compares the general inheritance with the super inheritance, from the results of the run, ordinary inheritance and super inheritance are the same, but in fact their internal operating mechanism is different, this point in multiple inheritance is evident, Need friends can refer to t
This is an object of its own, representing the object itself, which can be understood as: A pointer to the object itself.The usage of this can be broadly divided into 3 types in Java:1. Normal Direct referencesThis does not have to be said, this is equivalent to pointing to the current object itself.2. The name of the member who participates in the membership is distinguished by this:Class Person { private int: age = ten; Public person () { System.out.println ("Initialization Age:" +ag
Ext: 52205961The Python language has similar class inheritance to C + +, in which Python customizes the first self, like the this pointer in C + +, to the object itself.Examples of simple Python classes:[Python]View PlainCopy
>>> class Hello (object):
... def print_c ():
...print"Hello world!"
>>> hello (). Print_c ()
Hello world!
Of course, in practice, the inevitable need for class inheritance, subclasses inherit the parent class, normal as follows:[Python]View
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.