binding a reference to a variable

Erno Kuusela erno-news at erno.iki.fi
Tue Apr 9 16:40:54 EDT 2002


In article <yu994rikfzh5.fsf at europa.research.att.com>, Andrew Koenig
<ark at research.att.com> writes:

| I would like to be able to write an expression that yields an
| object that I can subsequently use to rebind a name that I mention
| only in that expression.  How do I do it?

[...]

| So far, the closest I've been able to come is this:

|         def set(var, val):
|                 var[:] = [val]

[...]
                
| Is it possible to do better (i.e., to solve this problem more succinctly)?

no - python likes to keep variables private to a scope.

  -- erno



More information about the Python-list mailing list