flask source code

1. In Python:
the end sign of functions, conditional statements and loop statements: when defining functions, conditional statements (such as if statements) and loop statements (such as for loops, while loops), the colon indicates the beginning of the code block, followed by Subsequent indented code blocks are considered part of the statement

Slicing operator: The colon can also be used for slicing operations, which are used to select subsequences from sequences (such as strings, lists, tuples, etc.). The syntax for the slice operation is [start:end]where startdenote the start index (inclusive) and enddenote the end index (exclusive)

Separators in dictionary comprehensions and set comprehensions: In dictionary comprehensions and set comprehensions, colons are used to separate key-value pairs.

2. Asynchronous programming understanding
Asynchronous programming: It can be seen as similar to the county seat but does not involve system scheduling, that is, asynchronous programs can handle problems concurrently when the context of the asynchronous program is not switched internally through the system scheduler.

3. What is coroutine? Coroutine is
also called micro-thread. It is executed in one thread. When executing a function, it can be terminated at any time. It is controlled by the program itself, and the execution efficiency is extremely high. Compared with multi-threading, there is no overhead of switching threads and multi-threading lock mechanism.

4. asyncio asynchronous coroutine
asyncio or Asynchronous I/O is a python package used to handle concurrent events. It is the basis of many python asynchronous architectures and is used to deal with high concurrent network requests.

5. await keyword
await is a keyword that can only be used in coroutine functions, and is used to suspend the current coroutine when encountering IO operations. In the process of suspending the current coroutine, the event loop can execute other coroutines. After the current coroutine IO processing is completed, the executed code can be switched again

6. The variable length parameter
 *args accepts a single parameter, and saves it as a tuple after receiving it

**kwargs receives parameters in the form of key-value pairs, and stores them in a dictionary after receiving them

7. The introduction of @property in python and
a decorator of python when using python's @property are used to modify the method. You can use the @propery decorator to create read-only properties. The @propert decorator will convert the method into a read-only property of the same name, which can be used in conjunction with the defined property, which prevents the property from being modified.


8. Python walrus operator definition
A variable name followed by an expression or a value, this is a new assignment operator.


9.python positional parameters
Python positional parameters are also called mandatory parameters. Refers to the actual parameters of the function that are correctly passed in when the function is called. The actual parameters passed in must be consistent with the formal parameters when the function is defined. The actual parameters and formal parameters must be consistent, and the order of actual parameters and formal parameters must be consistent.

10.python keyword parameter
Python keyword parameter refers to using the name of the formal parameter to determine the actual input parameter when calling the function. Python keyword parameters can avoid the trouble of remembering the position of parameters, making function calling and parameter passing more flexible and convenient.
 

Guess you like

Origin blog.csdn.net/NOguang/article/details/131952142