Python's talk about the definition of interfaces and abstract classes and abstract methods

Source: Internet
Author: User
#_ *_ coding:utf-8 _*_# knowledge Point: Interface definition and abstract class and abstract method ' 1, abstract type what? Abstract class plus abstract method is equal to interface 2, the definition of the interface 1, someone to expose you a URL, and then call the URL meaning 2, define a specification, do not write the implementation, according to this specification to implement the relevant functions, abstract class is the "from ABC import Abcmeta , abstractmethod# defines an abstract class class Alert: __metaclass__ = Abcmeta @abstractmethod def Send (self):p the #抽象方法class Foo (A Lert): #继承抽象类 (or inherited interface), you have to follow the specification of the abstract class Def __init__ (self): print ' __init__ ' def Send: #抽象类里有send方法, so, here too must To have the Send method print ' send '. Weixin ' F = Foo () f.send ()


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

Python's talk about the definition of interfaces and abstract classes and abstract methods

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.