Python's closures are basically read-only in the 2.x series. 3.0 will offer read-write access via the nonlocal keyword: http://www.python.org/dev/peps/pep-3104/
It still won't be exactly the same, because Perl uses `my $foo` once to declare its lexicals; Python will require `nonlocal foo` declarations in all scopes that will use `foo`. The final result is the same, though: using variables from outer scopes.
It still won't be exactly the same, because Perl uses `my $foo` once to declare its lexicals; Python will require `nonlocal foo` declarations in all scopes that will use `foo`. The final result is the same, though: using variables from outer scopes.