KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
In JS, we can write closure like: function f(){ var a=0; function g(){ alert(a++); } return g; } g=f() g() However, if I write following code in python def f(): a=0 def g(): a+=1 print a return g g=f() g() Then I get UnboundedLocalError . Can anyone tell me the difference between closure in python and JS?
Tags (comma-separated)
Save Edits
Cancel