Re:Understanding a Python Closure Oddity
by Jtsummers on Monday June 17, 2024 @01:21PM
(#40708270)
Correctly formatted (two spaces preceding each line, one blank line before the first code line, no extra lines needed between code lines):
The output:
It doesn't work because of the way Python's variables are scoped. Your fixed_number variable is still shared across all instances of inner. Python doesn't have any sort of block scoping like you seem to think it has.
[ Parent
| on HN ]
There are no comments on this comment yet.