Advanced Python Notes

Source: Internet
Author: User

Mu class net Python advanced http://www.imooc.com/learn/317 notes

# Start:

Pass

# to define the __init__ method of the person class, you can accept any keyword argument in addition to the name, gender, and birth, and assign them all as attributes to the instance:

class Person (object):

Count = 0 #定义类属性
def __init__ (self, name, gender, birth, **kw):
Self.name = Name
Self.gender = Gender
Self.birth = Birth
For K, V in Kw.iteritems ():
SetAttr (self, k, V)

Person.count + = 1

When instance properties and class attributes have the same name, the instance property has a high precedence, which masks access to the class properties.

Double underscore the property of "__xx" cannot be accessed directly externally, but the "__xx__" form of the property can be, many predefined special properties are used in this format

Advanced Python Notes

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.