We should also notice the familiar "dot" notation for asking an object to invoke a method. List.append(item) can be read as "ask the object List to perform its append method and send it the value item." Even simple data objects such as integers can invoke methods in this way.
(54).__add__(21)
In this fragment we are asking the integer object 54 to execute its add method (called __add__ in Python) and passing it 21 as the value to add.
Source from : https://runestone.academy/ns/books/published/pythonds/Introduction/GettingStartedwithData.html
'Language > Python' 카테고리의 다른 글
[OOP] Implement Logic Gates using Class Inheritance (0) | 2022.10.03 |
---|---|
[OOP] Creating Fraction Class using OOP (1) | 2022.09.30 |
[collections] Make frequency table automatically (1) | 2022.09.23 |
[chardet] Encoding and Representing Text (0) | 2022.09.22 |
[csv] Read files (0) | 2022.09.22 |