Dotted notation accesses an operation or property through an object: write the object, a dot, and the member name. For example, a.lower() changes the letters in string a to lowercase. Python uses this form for operations designed for a specific object type, such as strings. section 7.3 section 30.3
Read the expression from left to right:
- In "wow".replace("o", "a"), replace operates on a string. section 30.3
- In [1, 2, 3].append(4), append operates on a list. section 30.3
- In {1: 1, 2: 2}.keys(), keys operates on a dictionary. section 30.3
- len("lalala") uses a general function instead: the object goes inside the parentheses. section 7.3 section 30.3
Calling through an object
essay = "Ups AND Downs" print(essay.lower()) print(essay.upper()) Here, essay is the object. The dot selects a string operation, and the parentheses call it. Case conversion changes letters while leaving numbers and special characters unchanged. section 7.3
c = Circle() Circle.change_radius(c, 2) r = Circle.get_radius(c) print(r)
Compare ordinary object calls with explicit calls through the class name. c.change_radius(2) supplies c as self automatically; Circle.change_radius(c, 2) supplies it explicitly. section 31.6








