Python object-oriented member modifiers

Source: Internet
Author: User


A member modifier is a member of a set class, some of which are public, some are private, are exposed externally through objects, or classes can be called, but private can only be called through the inside of the class.

  • static field Decoration

  • #!/usr/bin/env python

  • # _*_coding:utf-8 _*_

  • class Foo:

  •    # 公有的静态字段

  •     classmembers

  •    # 私有的静态字段

  •    __ClassMembers = "私有的"

  • # 执行公有的静态字段

  • print(Foo.ClassMembers)

  • # 执行私有的静态字段

  • print(Foo.__ClassMembers)

  • /usr/bin/Python3.5 /Home/Ansheng/documentation/Python_code/Sublime/Week06/Day04/S2.py

  • 公开的

  • traceback most Recent Call last ):

  •   file line in <module

  •     ( Foo __classmembers )

  • attributeerror : type has no attribute "__classmembers '

  • Process finished with exit code 


This article from "A Candle" blog, declined reprint!

Python object-oriented member modifiers

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.