Python double underline method explanation

Source: Internet
Author: User

__init__Called after the class instance is created, some initialization of the instance of the current object, no return value __name__A system variable that identifies the name of the module __call__Whether it can be called __main__Main module module name (whether current module or import module) __new__A method that creates an instance of a class, called when an object is created, returns an instance of the current object __init__.pyThe import behavior of the primary control package __file__ represents the file itself, and the output is an absolute pathSys.path.append (Os.path.dirname (Os.path.dirname (Os.path.abspath (__file__))) __dict__Python has all the objects, each object has multiple properties (attribute), and Python has a unified management scheme for attributes.The difference between __dict__ and Dir ():Dir () is a function that returns a list;__dict__ is a dictionary, the key is the property name, the value is the property value;Dir () is used to find all the properties of an object, including the attributes in __dict__, and __dict__ is a subset of Dir ();? Not all objects have the __dict__ property. Many of the built-in types have no __dict__ properties, such as list, and you need to use DIR () to list all the properties of the object. __all__Define the __ALL__ variable at the beginning of the module, import the module, only the variables or functions that exist in the __all__ can be found, others cannot be called

Python double underline method explanation

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.