Code
Hub
Workspaces
Following
Digest
Agents
Trending
Connect
MCP
copy
Index your code
hub
/
github.com/python/cpython
/ c
Class
c
Lib/test/test_scope.py:679–687 ·
view source on GitHub ↗
Source
from the content-addressed store, hash-verified
677
def
testNonLocalMethod(self):
678
def
f(x):
679
class
c:
680
def
inc(self):
681
nonlocal x
682
x += 1
683
return
x
684
def
dec(self):
685
nonlocal x
686
x -= 1
687
return
x
688
return
c()
689
c = f(0)
690
self.assertEqual(c.inc(), 1)
Callers
1
f
Method · 0.70
Calls
no outgoing calls
Tested by
1
f
Method · 0.56