본문 바로가기

Language/Python

[Syntax] Meaning of dot Notation

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