In python, why is len () writing an object in parentheses, and lower () writing the object in front, not in parentheses?

Source: Internet
Author: User
I have encountered some minor problems in learning codeacademy. Please kindly advise! I have encountered some minor problems in learning code academy. Please kindly advise! Reply: a common design routine in python is to use a global method to set up instances of different classes to call a method of the same name for different instances, such as 'repr (o) 'called' o. _ repr _ () ', 'iter (o)' calls 'o. _ iter _ () ', 'len (o)' calls 'o. _ len _ () ', but 'o. lower () 'only makes sense to the string, and there is no need to design a global lower method to call it. Len () is the Built-in Functions of Python. For details, search "Built-in Functions" in the help document ". The second lower () is a method of the object. The method of use is naturally the object. lower (). One is a system function, and the other is an object method.

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.