What's the address for?

Chris Angelico rosuav at gmail.com
Tue Feb 19 12:58:52 EST 2019


On Wed, Feb 20, 2019 at 3:23 AM Grant Edwards <grant.b.edwards at gmail.com> wrote:
>
> On 2019-02-19, Ben Finney <ben+python at benfinney.id.au> wrote:
>
> >> On the implementation I am using, the ID changes if I do this:
> >
> > You are creating new objects and binding the name ‘a’ to different
> > objects in succession. Those different objects will each have different
> > identities.
>
> Those object _may_ each have different identies.  Is it required that
> they do?  If an assignment is done on name referring to an object with
> no other references, would it be allowed that the "old" object is
> destroyed and its ID reused for a new object being created by the RHS
> of the assignment?
>
> Admittedly, that would be a rather odd way to do things.  One would
> expect that first the RHS is evaluated (perhaps creating a new
> object), then the name is rebound.
>

Correct, the RHS is evaluated first. So the old object is still around
(important for statements like "x = x.lower()").

ChrisA



More information about the Python-list mailing list