Have you had a chance to go through the Python documentation, yet?
Under Dictionaries (
dict type) we find a number of useful methods, of which
values() gives us back a list of values, and
keys() gives back a list of keys, and
items() gives back a list of key-value pair tuples.
If I understand the question, are you asking how it is that we would write,
The dot means it is a method of the particular class that our object is associated with. In this case, we have what is determined to be a
dict object. That class of object has all the three previously mentioned methods, value, key, items. They are part of the class definition.
An object that belongs to a particular class (don’t worry, Python has it figured out which class it is) inherits all the methods and class attributes that go along with it. That’s why we can write,
my_dict is in fact a dictionary.