Content deleted Content added
→Does Haskell allow functions as keys in a map?: nicer example |
|||
Line 351:
</source>
: —''[[User:Ruud Koot|Ruud]]'' 11:57, 17 February 2011 (UTC)
Hi Ruud, Python 3 addressed the access to outer variables issue with the nonlocal keyword:
<source lang="python">Python 3.1 (r31:73572, Jun 28 2009, 18:34:47)
[GCC 3.3.4 (pre 3.3.5 20040809)] on linux2
Type "copyright", "credits" or "license()" for more information.
>>> def outer():
x = 1
def inner():
nonlocal x
x += 1
print(x)
return inner
>>> f = outer()
>>> f()
2
>>> f()
3
>>> f()
4
>>> </source> --[[User:Paddy3118|Paddy]] ([[User talk:Paddy3118|talk]]) 14:36, 17 February 2011 (UTC)
|