Python Nested call, namespace

Source: Internet
Author: User

Nested calls to Functions:

In the process of calling a function, another function is Called.

defprint(' frombar')  defPrint ('fromfoo') bar () foo ()

Nested Definitions of Functions:

In the interior of a function, another function is Defined.

A name defined inside a function that can only be used internally and cannot be used externally

def F1 ():     = 1    def  F2 ():        print('fromf2')         Print (x)     # Print Value        Print (f2)    # Print memory address     f2 () F1 ( )

Name Space:

Where the name is stored, exactly where the name and the value of the variable are bound

Also can be divided into: built-in namespaces, global namespaces, local namespaces

Built-in Namespaces:

Generated when the Python interpreter starts, storing some python built-in names, len (), if

Global Namespaces:

Generated when executing a file, holding the name of a file-level definition

X=1

def func ():
Pass

Import OS

Class Foo:
Pass

If x==1:z=3

Local Namespaces:

Python Nested call, namespace

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.