Python 3, an illustrated tour Transcripts
Chapter: Language syntax
Lecture: More laziness
0:01 One of the general themes of Python 3 is laziness
0:03 and so a lot of functions that returned lists in Python 2
0:07 are now lazy and behave as iterators,
0:11 either returning generators or views or something that is iterable.
0:15 So map, filter and zip, and range are all examples of this.
0:20 In Python 2, these returned lists, that is no longer the case,
0:23 they don't return lists anymore,
0:26 they are iterables that you can loop over.
0:28 Similarly, a dictionary in Python 3 has keys, items and views,
0:34 these same methods existed in Python 2
0:36 but in Python 2 these returned lists of what was in there.
0:40 These are now views, views are slightly special
0:43 in that they reflect any updates that are made to the dictionaries.
0:46 So if you're looping over it and it's been updated in the meantime,
0:50 you should get some values that update as well.