Review of the first four lessons

Source: Internet
Author: User
Tags generator generator

    1. Execution process

  650) this.width=650; "style=" height:214px;width:375px; "src=" http://images2015.cnblogs.com/blog/425762/201510/ 425762-20151024114048849-189055880.png "width=" "height=" 938 "alt=" 425762-20151024114048849-189055880.png "/ >

for CPython, It compiles, interprets, and finally runs on CPython virtual machines.

2. Outer variable, can be used by inner layer variable

An inner variable cannot be used by an outer variable-the inner variable is defined as global and can be used globally (and stack?). )

3. Boolean values

True false 1 or 0 empty word spaces list etc are false

4. Use of common variable types

String startswith endswith expandtabs partition replace

List Extend (iterable) insert (index,object) Pop (index)

Dictionary SetDefault (k,d) update ()

Collection Add Difference difference_update intersection intersection_update

Symmetric_difference symmetric_difference_update

Union update

5. Collection

Counter counter an ordered dictionary orderdict the default dictionary defaultdict a named tuple namedtuple

Bidirectional queue Deque

6. Iterator Iterator Generator generator

7. Shallow copy copies only the parent object and does not copy the child objects inside the object

Deep copy copy objects and their sub-objects

8. Built-in functions

VARs () dictionary type

__name__

9. Functions

FUCN (*args,**kwargs)

10. File operation

with open () as X, () as Y: Multiple files can be opened

A. Lambda simple function

Map Reduce Filter

13. Generator Yield xrange

14. The adorner functions as a parameter of a function

def auth (func):

def inner ():

print ' Before '

Func ()

print ' after '

return inner

@auth

Def f1 ():

print ' F1 '

F1 ()

@ Operation 1. The following function name F1 is passed as a parameter into the adorner function Àauth (F1)

2. Execute auth (F1), return to inner, equivalent to F1->inner, when executing F1 () becomes inner ()

If you touch @, you'll do it first.

You can use multiple adorners, which is equivalent to a few more boxes.

@deco1

@deco2

def fun ():

Three-layer Decorator

Review of the first four lessons

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.