- [Narrators] We move on from loops and iterators to two…powerful related concepts, comprehensions and generators.…Comprehensions are a way to run a loop within a single line…of code, and to collect the results of the loop…in a collection, such as a list.…Generators are a shortcut to write…functions that implement iterators.…Both are used extensively in Pythonic code.…In this video, we will learn how to write…list, dict, and set comprehensions,…how to use Python generator expressions,…and how to write Python generators.…

I'll begin by importing all the packages…used in this chapter.…I will also run a few lines of code that recover…the data structures that we built in the last video.…I read those from adjacent file that I open…and then load with adjacent package.…The Python designers realize that there are many situations…where you write a full loop to select the subset…of a sequence, operate on each selected element…individually, and collect the resulting modified elements…in a list, or in another collection.…

Resume Transcript Auto-Scroll

Author

Released

2/8/2017

Cut down on your development time by learning how to write elegant code in an efficient manner, specifically in Python—the popular and pragmatic object-oriented language. Michele Vallisneri explains how to make your Python code more expressive and concise, and leverage the most powerful features of the language. He shines a spotlight on some of the strongest third-party packages you can take advantage of, discusses object-oriented and functional programming, and shares strategies for improving the performance of your code. Michele illustrates these concepts with many intriguing examples, showing how to make 3D images and videos using photographs taken by a NASA rover on Mars, map the rover's progress through Martian topography, draw and paint fractals, and more.