how to write function that returns function

Erno Kuusela erno-news at erno.iki.fi
Thu May 16 03:08:25 EDT 2002


In article <4f52f844.0205151504.181f5cf0 at posting.google.com>,
spam at bugbear.com (Paul Graham) writes:

| Although you can't modify variables from outer scopes, you can
| modify *parts* of them (which to me seems like the same thing...)

you can dereference variables from outer scopes, but you cannot
rebind them to point to new objects.

you can change the objects the variables point to (if they are not
immutable, of course).

x += 1 would (potentially) re-bind the variable, ie set the name to
point to a new object, and you can't do that to variables from outer
scopes.

if your object had an increment() method, you could call that.

  -- erno



More information about the Python-list mailing list