Python function scope + adorner

Source: Internet
Author: User

Today's record is a small point of knowledge-the function scope + adorner:

Legb:l>e>g>b

l;local function Internal Scope

e:enclosing function inside and inline function

G:global Global scope

B:build-in built-in scopes

Coding && Result:

Closures ( Closure): An intrinsic function references a variable in the enclosing scope.

The role of closures:

1) package

2) Code Reuse

The nature and properties of the function:

1) function is an object

2) Internal variable recycling after completion of function execution

3) function is an object that has properties

4) function return value

Coding && Result:

Adorner: (for use with closures)

1) is used to decorate the function

2) Returns a function object

3) The decorated function identifier points to the function return object

4) grammar sugar @deco

5) Define the method with no parametric adorner and the basic flow:

6) Define with parameters

Coding && Result:

Python function scope + adorner

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.