Python 3, an Illustrated Tour Transcripts
Chapter: Language syntax
Lecture: No more name leakage
Login or purchase this course to watch this video and the rest of the course contents.
0:00 Another thing that Python 3 gave us is the lack of name leakage in comprehensions. This is something you may not be aware of
0:10 but variables were created during comprehension creation in Python 2 so an example shown here is I've got a variable called x
0:19 and I am looping over range 5 in a list comprehension using that same variable name x. In Python 2, x after that list comprehension
0:29 would be the last value of the iteration. In Python 3 that's no longer the case, these variables used in list comprehensions
0:37 don't go into your local or global name space, they stay isolated in your list comprehension. So x will stay 10 in Python 3, a slight difference there.
0:47 Okay, that wraps up most of the changes, we've seen in bunch of the other videos in this course,
0:52 a bunch of the new features and functionalities of Python 3, I just wanted to make sure that we talked about some of the other changes
0:58 that weren't easily found in peps or whatnot, but are some things that you should be aware of.