python--Multiple Inheritance

Source: Internet
Author: User

#方式一class  a ():     def __init__ (self, name):         self.name = name        print ("a  CLASS&NBSP, ...) class b ():     def __init__ (self, age):         self.age = age        print ("b  class ... ") class sub (a, b):     def __init__ (Self, name, age,  phone):         a.__init__ (self, name)          b.__init__ (self, age)          Self.phone = phone        print ("Sub class ...")      def get_all_info (self):         print (Self.name,  self.age, self.phone) if __name__ ==  ' __main__ ':     s = sub ("Toby",  25, 110)     s.get_all_info () #方式二class  a ():     def __init__ (Self,  name):        self.name = name         print ("A CLASS  ...") Class b (a):     def __init_ _ (Self, name, age):         super (B, self). __INIT__ (Name )         self.age = age         print ("B class ...") Class sub (b):     def __init__ (self,  Name, age, phone):         super (Sub, self). __init__ ( Name, age)         self.phone = phone       &nbsP; print ("Sub class ...")     def get_all_info (self):         print (self.name, self.age, self.phone) if __name__ ==  ' __main_ _ ':     s = sub ("Toby",  25, 110)     s.get_all_info ( )


python--Multiple Inheritance

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.