[Book Content] Python Advanced

Source: Internet
Author: User
Tags generator pprint

Python Advanced

Original book Content Https://github.com/eastlakeside/interpy-zh

Make a record by recording the book catalogue and the approximate content, so that we may review the search later.

More
Chapter Title Brief
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

[Book Content] Python Advanced

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.