Python: summary of function parameters

Source: Internet
Author: User

Type of parameter:

There are 2 types of parameters for a function:

1. function definition is used to receive the form parameter parameters of the value.

2. The actual parameter arguments used to pass the value when the function is called.

Parameters are passed:

There are 2 ways of delivery:

1. Value passing: Copies the value of an argument to a parameter, regardless of whether the value is the original value, the pointer value, or the heap object value.

2. Reference passing: References the same object to the shape participation argument.

There are 2 forms of delivery:

1. Pass by Position:

2. Pass by name:

Definition of formal parameters:

The formal parameters of a function can be divided into:

1. General parameters

2. Default parameters: Parameters with default values

3. Variable-length parameters: According to the transfer parameter transfer form is divided into

(1) Variable length position parameter, receive using *seq object.

(2) variable length named parameter, received using **dict object.

The default parameter must be after the normal parameter

The variable length parameter must be after the default parameter

Variable-length named arguments must be after the variable-length position parameter

Python: summary of function parameters

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.