Python's Simple chat class inheritance

Source: Internet
Author: User

#_ *_coding:utf-8 _*_# Parent class class father:    def __init__ (self):         self. fname =  ' fffffff '     def func (self):         print  ' FUNCFURNC '     def bar (self):         print  ' Barbarbar '     def test (self):  #再定义一个方法          print  ' 11111 '         print   ' Testtest ' #子类继承父类, that is to say Son class can get Father class method Class son (Father):     def __init__ (self):         self. sname =  ' Sonsonson '     def yes (self):         print  ' Barbarbar '     def test (self):         print  ' aaaaaaAA '      #重写父类的Test方法 # instantiates subclasses, tries to access Methods S1 = son ()   #实例化子类s1 in the parent class. Bar ()      #成功访问父类的方法s1. Test ()     #访问重写后的方法f1  = father () F1. Test ()
#_ *_coding:utf-8 _*_# Multiple Inheritance Class A (object): Def __init__ (self): print ' The ' A ' def Save (self): print ' Save method from A ' class B (a): Def __init__ (self): print ' This is B ' class C (a): Def __init__ (self): p Rint ' This was C ' def Save (self): print ' Save method from D ' Class D (c,b): def __init__ (self): print ' th IS is d ' C = d () c.save ()


This article is from the "Fa&it-Q Group: 223843163" blog, please be sure to keep this source http://freshair.blog.51cto.com/8272891/1874313

Python's Simple chat class 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.