In this lesson, you will learn an alternative approach to functional programming in Python, that is specifically encouraged in Python3, iterators and comprehensions. First, you will learn about list comprehensions, which are an easy way to construct lists of items. Second, you will learn about iterators, which enable functional programming by simplifying the process of moving through items of data in a collection, like a list. Finally, you will learn moe about these constructs through a worked file system example.
###Objectives ### By the end of this lesson, you will be able to:
- Understand the iterator concept and how they can be broadly applied.
- Understand how to use a list comprehension to make a new list.
- Understand how to use an if clause in a list comprehension.
- Understand other comprehensions like dictionary or set.
Approximately 3 hours.
-
Python Tutorial on list comprehensions
-
Python HowTo article on Functional Programming. Stop when you reach the Generator subsection.
-
Python List Comprehension tutorial.
-
Python HowTo article on Functional Programming. To master FP concepts in Python3, I would encourage you to read the rest of this HowTo.
When you have completed and worked through the above readings, please take the Week 11 Lesson 3 Assessment.