1 |
*ARGV and **KWARGV |
To input a variable parameter to a function |
argv as a list,kwargv as a dictionary |
2 |
Debug PDB |
Breakpoint debugging at the code level |
|
3 |
Generator |
Defines a __iter__ or __getitem__ as an iterative object that defines __next__ as an iterator |
The usefulness of yeild |
4 |
Map, Filter and Reduce |
|
-Map maps a function to all functions on a list, map (function_to_apply, list_of_outputs). Python3 returns an iterator that lists the list. -Filter filters The elements in the list and returns a list of all the elements that meet the requirements. -Reduce can perform some calculations on a list and return results, similar to merge. |
5 |
Set data structure |
Set cannot contain repeating elements |
-Intersection: Set1.intersection (Set2) -Difference set: Set1.difference (Set2) |
6 |
Decorative Device |
There are other things to do during the execution of a function, you can use adorners, and more simply define adorners and use @ |
|
7 |
Object Change Mutation |
|
Note The default value, and the Python default value is only initialized once |
8 |
__slots__ Magic |
|
Save small classes of resources |
9 |
Virtual Environments |
Virtualenv |
|
10 |
Collections |
Defaultdict, Counter, deque, Namedtuple, enum. Enum |
|
11 |
Enumeration enumerate |
|
|
12 |
Object Introspection (Introspection) |
Dir, type, ID, inspect |
|
13 |
Derivation formula (comprehension) |
Construct a new data series from one data series structure of eg. List, Dict, set |
The set's push-down is {}, because () the iterator is generated |
14 |
Abnormal |
Try, except, finally, else |
No matter whether the touch does not trigger the exception to execute finally, the exception does not trigger the Execute else |
15 |
Lambda expression |
Lambda parameters: Actions (Parameters) |
|
16 |
One-line |
Simple webserver Nice print. Scripting Performance Analysis CSV to JSON List flat Row constructor |
Python3-m Http.server From Pprint import Pprint Python-m Cporfile my_script.py ... |
17 |
For else |
Execute the Else statement when the loop is fully executed |
|
18 |
Using the C extension |
cTYPES, SWING, python/c API |
|
19 |
Co-process |
If the iterator is the creator of the data, then the process is the consumer |
Line = (yield), through the external send to the association, you can execute the subsequent if pattern in line, close with close () |
20 |
function cache |
The function cache allows us to cache a function for the return value of a given argument. |
@lr_cache (maxsize=32), clearing the cache using Function.cache_clear () |
21st |
Context management (with syntax) |
Class-based implementation of __ENTER__ and __exit__ Handling Exceptions Generator-based @contextmanager |
|