Skip to content

Instantly share code, notes, and snippets.

@kumagi
Created January 20, 2015 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kumagi/b9af519cda3d8ec71e79 to your computer and use it in GitHub Desktop.
Save kumagi/b9af519cda3d8ec71e79 to your computer and use it in GitHub Desktop.
pythonのクロージャ…
def hoge():
x = []
def append(v):
x.append(v)
def printOut():
print(x)
return (append, printOut)
appender, printer = hoge()
appender(1)
appender(2)
appender(3)
printer()
a, b = hoge()
a(4)
a(5)
a(6)
b()
printer()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment