I was learning Python dictionaries at W3Schools:
car = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
x = car.items()
print(x)
I get:
dict_items([('brand', 'Ford'), ('model', 'Mustang'), ('year', 1964)])
The dict_items
looks like a conversion function or class constructor, but it is not recognized at the command line:
>>> dict_items([('brand', 'Ford'), ('model', 'Mustang'), ('year', 1964)])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'dict_items' is not defined
The most authoritative explanation I found is the Python documentation on dictionary view objects, but it still doesn't say anything about what dict_items
is. Is it just a constructor that is not accessible to the public?