Lesson 14


#1

I have manage to take every lesson and make it work in python 3.5 with pycharm. I am doing this primarily to learn the differences between the two versions of python. So far almost everything has been pretty straight forward. Add a couple of parentheses here, make sure there are the right indents there and everything has worked.

However for some reason this lesson will not work with 3.5 is the filter expression removed in 3.5?


#2

In Python2 the result is a list, in Python3 it's a generator/iterator. A generator is something that you can iterate through, the biggest difference is that it doesn't compute any of the elements until you pull them out of the generator (it's lazy). You can convert it to list or some other container by passing it to that class, or use a for-loop.

map got a similar treatment.

Both map and filter can be replaced by list comprehension/generator expressions and those are just.. nice, so there's not much reason to use map/filter anyhow. That's not saying that the generators are a hindrance, more that the functions aren't that useful to begin with.