Problem Python function 008 (2)

1. Yesterday Recap:

def function ():

     Function body

     return value

If you do not write return, default return None. Can return a single value, multiple values ​​can be returned as a tuple. (Not to be confused print and return)

Positional parameters, keyword parameters, default parameters, mixing parameters

Front position parameters in keyword arguments

The default value of the parameter can be modified further where arguments, return the modified values. If you do not modify the default value.

 

2. Today's content:

Parameter classification:

Positional parameters, keyword parameters, dynamic parameters

2.1 Dynamic parameters:

① dynamic parameter receiving position parameter

② dynamic parameters to receive keyword arguments

In a position parameter plus '*' represents any received content (dynamic position parameter), a dynamic (Dynamic position parameter) is a parameter output tuple

 

Dynamic parameters have to be back in the position parameter.

 

The default parameters on the dynamic behind parameters:

Sequence: position parameters, the dynamic parameters, the default value of the parameter

 

The final order:

Location parameter> dynamic positional parameters (* args)> The default value of the parameter> Dynamic keyword arguments (** kwargs)

Receive all parameters:

 

 

Another dynamic parameter reference transmission mode:

  • l * numbers can be used iterative sequence (string and list) in order to break up

 

  • l Use ** No dictionary can be broken up

 

 

 

Namespaces
Python at the start of the operation, it will open up a space in memory. Encounters a variable, put the relationship between variable names and values recorded. When confronted with the function definition interpreter just written to memory function name, it indicates that this function already exists. Functions are not to be concerned about the interpreter. Only when the function is called and visited, the interpreter will be based on the variables declared inside a function to open up the internal space variables. With the function completes, the space occupied by these internal variables also with the function completes, and is cleared.

 

 

The store name - the spatial relationship of values ​​called: namespace. Variable storage time is stored in this space.

After the Notes :( function declaration function, write three single quotes, pop Comment button)

 

 

Guess you like

Origin www.cnblogs.com/oito/p/11233704.html