To learn Python, I am referring 'Learning Python' by Mark Lutz. So, while going through its Chapter 20 (Comprehensions and Generators) it said that
Fundamental built in tools such as range, map, dictionary keys and files are now generators
I agree with statement for range, map and files, since, when I run following command I receive an 'Object' instead of complete data:
range(3)
returns
range(0,3)
and map(abs,[-1,-2,3,4])
returns
<map object at 0x0000025B92164040>
However, when I type this:
d = {1:1,2:2}
d.keys()
I get: dict_keys([1, 2])
i.e. full list of keys in form of list.
So, if the d.keys() method displays all keys at once in form of list instead of returning an object like range and map, then how the method is referred to a Generator?
P.S.: I am using Python 3.7 and the book is probably written for a lower version