Python 3 Program Development Guide (2nd edition revision) Notes

Source: Internet
Author: User

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

Python 3 Program Development Guide (2nd edition revision) Notes

Related Article

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.