anything like C++ references?

Tom Plunket tomas at fancy.org
Mon Jul 14 20:06:17 EDT 2003


Tom Plunket wrote:

> What I specifically want is a way to have a "second-level
> binding", e.g. a reference to a reference (assuming that the
> terminology is correct by saying that all Python variables are
> references).  This is where I see the hole in Python, that there
> actually is a class of object that is different from everything
> else; you can bind to anything at all in the language...except
> references.

I just realized that this would be silly, complex, etc.

Say you could (as another poster mentioned) do something like
this:

>>> a = 5
>>> b = ref_to(5)
>>> a = 3
>>> print b
3

This would require a new built-in probably, and any time you
(accidentally?) did 'b = c', then you'd lose that reference,
but...  hmm, I wonder if it'd be handy.

Probably not enough to justify the expense.  :)

-tom!




More information about the Python-list mailing list