[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

What's the address for?

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()").