python\ function 2

Source: Internet
Author: User

I. Namespaces and Scopes

Name Space classification:

Built-in namespaces

Import this

Dir (buil-in) View all built-in

Global namespaces

Local name space

Within the function body, etc.

Querying Global and Local

The Globals () method can get global content

The global content that the method obtains is the global content that was previously defined by the program when it was called

The locals () method can get local content

Two. Function nesting

function nested call

Other functions are called inside the function

Nested Definitions of functions

Define other functions inside a function

Three. Function object and Closure

A function is the first class of objects
Functions can be assigned values
Pass the function as a parameter
Take a function as a return value
Use the function as an element of the container type.

Definition of closures:
Defined to internal functions include the use of external scopes, but not the use of global scopes
Return value for the closure pack
Features: self-taking parameters



python\ function 2

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.