Show More
@@ -113,7 +113,7 b' An example of a function that uses a closure:' | |||||
113 | def inner(): |
|
113 | def inner(): | |
114 | # inner will have a closure |
|
114 | # inner will have a closure | |
115 | return a |
|
115 | return a | |
116 |
return |
|
116 | return inner | |
117 |
|
117 | |||
118 | f1 = f(1) |
|
118 | f1 = f(1) | |
119 | f2 = f(2) |
|
119 | f2 = f(2) | |
@@ -135,7 +135,7 b' outer function, then there will not be a closure, and the generated function wil' | |||||
135 | def inner(): |
|
135 | def inner(): | |
136 | # this inner will *not* have a closure |
|
136 | # this inner will *not* have a closure | |
137 | return a |
|
137 | return a | |
138 |
return |
|
138 | return inner | |
139 | g1 = g(1) |
|
139 | g1 = g(1) | |
140 | g2 = g(2) |
|
140 | g2 = g(2) | |
141 | g1() # raises NameError on 'a' |
|
141 | g1() # raises NameError on 'a' |
General Comments 0
You need to be logged in to leave comments.
Login now