On 25/05/21 9:27 am, Cameron Simpson wrote:
On 24May2021 16:17, hw <h...@adminart.net> wrote:
>
Or it doesn't forget
about the old one and the old one becomes inaccessible (unless you
have a reference to it, if there is such a thing in python).  How do
you call that?

You're conflating values
(objects, such as an int or a string) with variables (which _are_
references in Python,

I think hw might have meant the C++ notion of a reference to
a *variable*. There is no equivalent of that in Python.

Python does have references to *objects*. All objects live on
the heap and are kept alive as long as there is at least one
reference to them.

If you rebind a name, and it held the last reference to an
object, there is no way to get that object back.

On the other hand, if you shadow a name, the original name
still exists, and there is usually some way to get at it,
e.g.

>>> int = 42
>>> int
42
>>> __builtins__.int
<class 'int'>
>>>

--
Greg

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to