python-built-in class properties

Source: Internet
Author: User
Tags class definition

Python built-in class properties
    • __DICT__: Properties of the Class (contains a dictionary, consisting of the data properties of the Class)
    • __DOC__: Document string for Class
    • __NAME__: Class name
    • __MODULE__: The module where the class definition resides (the full name of the class is ' __main__.classname ', if the class is in an import module mymod, then classname.__module__ equals Mymod)
    • __BASES__: All parent classes of a class make up elements (containing a tuple of all the parent classes)

The python built-in class property invocation instance is as follows:

#!/usr/bin/python#-*-Coding:utf-8-*-Class Employee: ' base class for all employees 'Empcount= 0 Def__init__(Self,Name,Salary): Self.Name=NameSelf.Salary=SalaryEmployee.Empcount+= 1 DefDisplaycount(Self): Print "Total Employee%d" % Employee.EmpcountDefDisplayemployee(Self): Print "Name:", Self.Name, ", Salary:", Self.SalaryPrint "Employee.__doc__:", Employee.__doc__print  employee. __name__print ,< Span class= "PLN" > employee.print ,< Span class= "PLN" > employee.print ,< Span class= "PLN" > employee.                

Execute the above code to output the result as follows:

Employee.__doc__: Base class for all employeesEmployee.__name__: EmployeeEmployee.__module__:__main__Employee.__bases__: ()Employee.__dict__: {' __module__ ': ' __main__ ', ' Displaycount ': <functionDisplaycount at0x10a939c80,  ' empcount ' : 0,  ' displayemployee ' : <function Displayemployee at 0x10a93caa0< Span class= "pun" >>,  ' __doc__ ' :  ' \XE6\X89\X80\XE6\X9C\X89\XE5\X91\X98\XE5\XB7\XA5\XE7\X9A\X84\XE5\X9F\XBA\XE7\XB1\XBB ' ,  ' __init__ ' : <function __init__ at 0x10a939578 >}               

Python-built-in class properties

Related Article

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.