The tenth chapter: Pythonの Network Programming advanced

Source: Internet
Author: User
Tags for in range

The main topic of this lesson
    • Scope Additions in Python
    • Socketserver Source
    • Homework this week

Scope Additions in Python
  1. There are no block-level scopes in the Python world .: cannot print name in java/c+ world.
    # can't print name in java/c+ world. # but in the Python/javascript world, you can print name. if 1 = = 1:      ... ' Janice '  Print(name) Janice
    no block-level scope in Python (small knowledge point one)
     for  in range: ...     =print(name)9
    no block-level scope in Python (small Knowledge Point II)
  2. But in the Python/javascript world you can print name. In Python, a function is used as the scope.
     >>> del   name  >>> def   Func (): ... name  = "  janice   "  ...  >>> print    <STDIN>  Span style= "color: #800000;" > ", line 1, in  <module>nameerror: Name   name    is  not  defined 
    in Python, a function is used as a scope (small knowledge point III)
  3. Python is a scoped chain, and for the scope, its scope has been determined before the function is executed, and the scope chain has been determined.
    ' Alex ' # This is F1 () is a scope, it is an internal scope def F1 ():      ... Print  #  This is F2 () is scoped def  F2 (): ...      ' Eric ' ...      >>> F2 () Alex
    Python is a scoped chain (small knowledge point four)
    >>> name ='Alex'# This is F1 () is a scope, it is an internal scope>>>defF1 (): ...Print(name) ...#this is F2 () is a scope>>>defF2 (): ... name='Eric'...     returnF1 ...>>> ret =F2 ()>>> ret ()#this is equivalent to running F1 ()Alex
    Python is a scoped chain (small knowledge point five)
  4. for Loop, then add 1 to each element, and finally generate a list
    # it executes a for loop, then adds 1 to each element, and finally generates a list  forif x > 6]print(LI)
    Python Lambda + for loop (small knowledge point six)
    >>> Li2 = [lambda for in range]>>> ret = li2[0] () Print (ret)9
    Python Lambda + for loop (small knowledge point seven)
    >>> li = [] for in range: ...      def F1 (x=i): ...         return x     ... ...      Print (Li[0] ()) 0 Print (Li[1] ()) Print (Li[2] ())2
    Python Lambda + for loop (small knowledge point eight)

Socketserver Source

I used IO multiplexing.

Multithreading, multiple layers, and processes

Homework this week

Day10 Job

References

Silver Horn King: the path to Python "seventh": threads, Processes, and co-routines

Golden Horn King:

The tenth chapter: Pythonの Network Programming 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.