Binding a variable?

Mike Meyer mwm at mired.org
Sat Oct 22 20:21:11 EDT 2005


Steven D'Aprano <steve at REMOVETHIScyber.com.au> writes:

> On Fri, 21 Oct 2005 13:33:18 -0400, Mike Meyer wrote:
>
>> Paul Dale <pd at traxon.com> writes:
>> 
>>> Hi everyone,
>>>
>>> Is it possible to bind a list member or variable to a variable such that
>>>
>>> temp = 5
>>>
>>> list = [ temp ]
>
> Don't use the names of built-in functions as variables.
>
>>> temp == 6
>>>
>>> list
>>>
>>> would show
>>>
>>> list = [ 6 ]
>> 
>> No. You need to either put a mutable in the list, or subclass list so
>> that indexing gets the value, looks it up in the appropriate
>> namespace, and returns that value.
>
> Or something even conceptually simpler than having to muck about with
> looking up different namespaces:
[elided]

Um, that's the *first* solution I proposed: putting a mutable on the
list.

        <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list