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
0:02 is the lack of name leakage in comprehensions.
0:06 This is something you may not be aware of
0:09 but variables were created during comprehension creation in Python 2
0:13 so an example shown here is I've got a variable called x
0:18 and I am looping over range 5 in a list comprehension
0:21 using that same variable name x.
0:23 In Python 2, x after that list comprehension
0:28 would be the last value of the iteration.
0:31 In Python 3 that's no longer the case,
0:33 these variables used in list comprehensions
0:36 don't go into your local or global name space,
0:39 they stay isolated in your list comprehension.
0:42 So x will stay 10 in Python 3, a slight difference there.
0:46 Okay, that wraps up most of the changes,
0:48 we've seen in bunch of the other videos in this course,
0:51 a bunch of the new features and functionalities of Python 3,
0:54 I just wanted to make sure that we talked about some of the other changes
0:57 that weren't easily found in peps or whatnot,
1:01 but are some things that you should be aware of.