While working with the database I have noticed something, especially Python ORM which deal with the database.
Here is an example of the Also in the Google app engine, where the function Now, I think why we do this, IIRC, we Do this because we are not manually using the Anyone please give me a more detailed explanation about why to save the work in such a way. I understand this is my mistake, because I had learned through going and coding, but I actually I can not understand that when I type You are currently viewing a method that overrides in a sub-class. The purpose of subclassing is to reuse the code and override functionality as needed, sometimes it involves overriding the method and calling its parents' pieces. This is not exactly what is subclassing: On the contrary, if we write a method without a super call It is If we want to supplement the functionality (i.e. retaining the old behavior but something that The Hen extra) We use super to call from within the new method the original pattern. save () function in Dijongo:
def save (self, ** kwargs): self.somevar = Dosomething (self.somethervar) is back super (
is inserted () is used:
def put (self, ** kwargs): self. & Lt; Some_var & gt; = DoSomething (self.someOtherVar) returns super (
put () or
save function, so we use super call to make it work properly Will happen.
save () or
) function
Super calls the method of the original class
Def Save (...): Return Super (MyClass, self) .ave (...)
druf (...): print ("I have nothing with parent class") < / Code>
def Save (...): Print ("I'm directly told before the original root method") Returns Super (MyCalus, Self) Savings (...)
No comments:
Post a Comment