O'Reilly logo
  • You Wang thinks this is interesting:

Because each call to the outer function produces a new nested function object, this scheme supports multiple copy per-call changeable data just like nonlocal closures and classes—a usage mode that global variables cannot provide:


Cover of Learning Python, 5th Edition


func attr is multiple copy, global attr is one copy