Python First knowledge function two

Source: Internet
Author: User

1. Dynamic parameters of a function

1.*args positional Parameters Dynamic parameter transfer

2.**kwargs keyword parameter dynamic argument

Order: Position parameter, *args, default value, **kwargs

def func (*args, * *Kwargs)            :         The position of the pass parameter *,**:        The location of the aggregation argument *,**: Scattered

2. Namespaces

1. Built-in namespaces

2. Global namespaces

3. Local namespaces

Scope:

1. Global scope: Built-in + global

2. Local scope: function call

Globals () to view the contents of the global scope

Locals () to view the contents of the current scope

3. Function nesting

Functions can be nested with each other

4.global and nonlocal

Global : Content in local access global nonlocal: The variable closest to him in the local search for the outer function

  

Python First knowledge function two

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.