Python 3 Program Development Guide (2nd edition revision)Directory
- 1 process-oriented programming Quick Start
- 2 Data Type
- 3 Combination Type
- 4 control structures and functions
- 5 Module
- 6 OOP
- 7 file Processing
- 8 Advanced Programming Techniques
- 9 commissioning, testing and profiling
- Ten Processes and Threads
- One Network
- A Database
- - Regular Expressions
- - Analysis Introduction
- the GUI
process-oriented programming Quick Start
- For in
- Try except as
Data Type
- Sys.float_info.epsilon
- Seq[start:end] actually represents [Start, end] interval, s[:] equivalent to S[0:len (s)]
- Inconsistency: When using negative step, start defaults to -1:s[::-2]
- Strtemplate.format (Agr0, arg2, name1=value1,...)
- {0} {1} {2} ...
- {name1} {name2} ...//Mix the numbering parameter in front, the named parameter is placed in the back
- Use local variables in the current scope range? **locals ()//locals () returns a dictionary, * * split it
Combination Type
- Sequence: ByteArray, Bytes, list, str, tuple
- Collections.namedtuple
- List split: first, *rest = [1,2,3,4]
- List understanding: [Expr for I in L]
- Set: Set
- Set understanding: {Expr for i in S}
- Mapping: 3.0 dict, collections.defaultdict,3.1 collections. Ordereddict
- SetDefault: Prevents d[k]+=1 such a grammar from being thrown keyerror the first time it is called
control structures and functionsModuleOOPfile Processing
- Bytes.fromhex?
- F.seekable ()
Advanced Programming Techniques
- Generator: The creator uses yield to return lazily, and the caller for in gets the
- Reset Current Value: Generator.send (Val), Val as result of yield expression accepted
- Dynamic Import Module: The most primitive method
- Code = open (filepath, "R", encoding= "UTF8"). Read ()
- module = Type (SYS) (name)
- Sys.modules[name] = module
- EXEC (code, MODULE.__DICT__)
- Adorner: high-order function, Original_func--and Wrapped_func (here's a major obstacle to understanding is *args, **kwargs parameter syntax)
- Function Note: __annotations__
- functor:__call__
- Context Manager: With expr as Var:suite
- The result of expr return must implement __enter__ __exit__, such as the file object returned by open ()
- Descriptor *:__get__ __set__ __delete__
- __slots__ = ()
- Class Decorator:---Class '
- Nonlocal
- ABC (abstract base class)
- Meta-class (? )
FP
- Functools.partial
- @coroutine: Call the built-in next () for the coprocessor to execute to the first yield and wait for
- Composition Line *
commissioning, testing and profiling
- p366 Python 3 is one of the advantages of distinguishing between str and bytes?
- Python 3.0 Exception chain support: Raise Newexception (...) from err
Processes and ThreadsNetworkDatabaseRegular Expressions
- Negative outlook: (?! E
- M.span (g): Returns the starting accept index position of the group G in the text (start,end)
Analysis Introductionpyparsing
- Elements: Literal (), Supress (), Keyword () (must match all words)
- Word ("abc") matches Abacus?
- Charsnotin () Skipto () Regex ()
- Forward () empty elements?
- Quantification: Optional (), Zeroormore (), Oneormore (), Group (), Combine ()
- The customary method of dealing with BNF:
- Do not write Item | Empty (), but optional (item)
- Variable list: var_list = variable + zeroormore (supress (",") +variable)
- Set action:. Setparseaction (lambda tokens: ...)
- Analyze first-order logic *:
- Example: (ForAll x:exists y:true), True & ~true-True
- Parseelement.enablepackrat ()
PLY
- T_tokenname P_bnf_rule ...
GUI
Python 3 Program Development Guide (2nd edition revision) Notes