in reply to Re^9: Closures and scope of lexicals
in thread Closures and scope of lexicals
subrefs = [] for j in range(1,4): def subref(): print( j ) subrefs.append( subref ) for subref in subrefs: subref()
3 3 3
Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^11: Closures and scope of lexicals
by ikegami (Patriarch) on Oct 31, 2024 at 17:51 UTC | |
by LanX (Saint) on Oct 31, 2024 at 18:36 UTC |