Variable scope and object-oriented programming

Python basis

QR code (Quick Respone Code)

Also referred to as QR code, which is a two-dimensional planar pattern of small squares composed of two different colors, which is a data (typically a string) is encoded as a two-dimensional code image scanner can quickly identify dimensional code image data (i.e., decode)

 

Variable scope (Scope) problem

Scoped variables: Code scope variables can be accessed

According to different scopes, variables can be divided into local and global variables (Free Join)

Python interpreter cited in the search argument is to comply with the rules LEGB

L: Local, i.e. internal functions scope

E: Enclosing, the outer nested function scopes

G: Global, global scope

B: Built-in, built-in scope

 

In addition to the function calls can be nested, nested definitions may

 

Closure (Enclosing)

Local variables defined inside remain after the function returns

 

To achieve the defined function must be nested closure

 

Version Control System

Version Control System, referred to as VCS, mainly to solve the problem of file version management, divided into centralized and distributed VCS VCS

Centralized VCS: SVN, etc.

Distributed VCS: GIT, etc.

 

Master the common usage of GIT

GIT three important concepts: work areas, staging areas, warehouse

git log View Log

git reflog view operating information for all changes warehouse

git status to view the status of the work area

git reset --hard HEAD return to the last change

 

 

Object-Oriented Programming

Oriented Object Programming, referred to as of OOP, a programming idea, that the basic units of OOP program object (instance), the interaction between different objects to achieve the various functions of the program

Process-oriented programming function that is a basic unit constituting the program, the order of execution of a set of functions to achieve the various functions of the program

OOP is a programming language development trend

OOP is achieved by classes and objects; objects (Object) is also called an instance (instance), any particular things are an object class (Class) having the same attributes (the Attribute, i.e., data) and methods (Method,, That behavior) of all objects or abstract collection

From the perspective of data types, the class is actually a custom data type, and the object is the data belongs to a specific data type

 

restriction of visit

One or two names begin with an underscore are private properties and methods represent, that they can only be accessed in the class, do not access them outside the class, although Python does not provide grammar rules to ensure this, but we have to consciously abide!

 

Property (Attribute)

Examples of attributes are divided into (Instance Attribute) and class attributes (Class Attribute), all belonging to the object instance properties, each object has its own independent of a property can only be accessed through the object name, and property belonging to the class of all classes, all objects a shared, can be accessed through the class and object names

In the actual development, to avoid class instance attributes and attributes with the same name

 

 

Spread

In addition to 1.Python object class has no parent rest

2.windows below begins with a dot is not a hidden file, but the file is hidden attribute

3. The root causes of garbage generated: codec is inconsistent, it is recommended to use a unified utf-8

Here 4.windows newline is \ r \ n, Linux is below newline \ n

5.vim into the automatic formatting ctrl + v = visualized by two to

6. The binary conversion! !

 

 

Guess you like

Origin www.cnblogs.com/yanruizhe/p/11240339.html