Python: function brackets. The difference between function brackets and function parentheses.

Source: Internet
Author: User
For example, function: def A (x): def B (y): Return x + y return B. The last return B function has no parentheses, but the function runs normally, when a (2) (3) is called like this, the value can be calculated normally. What is the returned B? What should I do? In addition, when a (2) is missing a parameter call, it is useless and does not cause an exception. How should I understand him?
In this way, you can see that this method cannot pass X to B to Def B (y): Return x + ydef A (x ): return B in fact, you call a --> Print the memory address of A. A (x) is the method A that is called, and return B is equivalent to printing the memory address of B directly, so a --> function a's memory address a (x) --> call method A and return function B's object equivalent to --> BA (x) (y) --> B (y) call Method B to return the values of X and Y. Here, X is the parameter value of method A, and Y is the parameter value of Method B. This can understand the parameter scope.
Related Article

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.