day02 python-- Advanced Object-Oriented

Python identifiers

In python, the identifier is made up of letters, numbers or underlines.

In python, all identifiers can include letters, numbers, and the underscore (_), but can not start with a number.

python identifier is case sensitive.

Starts with an underscore identifiers is of special significance. It begins with a single underscore _foo class representatives can not directly access the property, to be accessed through an interface class.

In the private members of class representatives __foo beginning double underlined, double underlined to __foo__ Representative python in particular beginning and end of specific identification method, such as __init __ () representative of the class constructor.

python can show the same row multiple statements, method is to use a semicolon; separated

__a private variables

  Can not be inherited; you can call in the class, not invoked externally.

  When the variable is particularly important with an underscore to indicate private

E.g:

@property accessor and modifier @ XXX.setter

E.g:

In python, dynamic class

E.g:

__slots__ magic variables

Necessary to define a custom type object can only bind certain properties, can be defined in a class _ _ slots _ _ to define variables. Note that _ _ slots _ _ limited only to the current class of objects into effect, sub-class does not play any role.

Case: E-mail registration

 

Guess you like

Origin www.cnblogs.com/hisashi-mitsui/p/11318128.html