Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Certainly, but you don't even need closures for this:

  def foo():
    a = []
    append_foo(a)
    return a

  def append_foo(a):
    a.append('foo')
But then I wouldn't call this "local mutability", in the sense that you modify your list in a different part of the code. Not a problem in a trivial example like this, definitively an issue when the actual action performed is ten levels deep.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: