Python operator overloading

Source: Internet
Author: User

Operator overloading is the interception of built-in operations in a method (a special method of double underlines)--when an instance of the class appears in a built-in operation, Python automatically calls the custom method and returns the result of the action of the custom method.

You can have the class intercept regular Python operations.

Callable object: __call__ ()

Functions: Built-in functions, custom functions, Def, Lambda

Class

Class method

Properties of the function:

__doc__

__name__

__dict__

__code__

__globals__

Properties of the method:

__doc__

__name__

__func__

__class__

__self__

Properties of built-in functions:

__doc__

__name__

__self__

Class:

__doc__

__name__

__bases__

__dict__

__MODULE__: Defines the module name of the current class

  

Instance:

__class__

__dict__

Objects have special methods:

__init__,__new__,__del__

__DIR__ () __add__ () __ge__ ()

A >= b A. __GE__ (b)

Python operator overloading

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.