How is the execution order of 'x = z'? (also: Python FAQ 4.88)

Ulrich Petri ulope at gmx.de
Tue Jul 22 15:13:16 EDT 2003


"Ames Andreas (MPA/DF)" <Andreas.Ames at tenovis.com> schrieb im Newsbeitrag
news:mailman.1058894315.10480.python-list at python.org...
> Hello,
>
> during execution of an assignment statement like
>
> x = y
> x = z # <--
>
> is y's reference count decremented (and therefore its __del__ possibly
> called) *before* x is bound to z (or is z bound to x, I don't know the
> correct wording) or *afterwards*?

No.
1. its not y's reference count that gets (possibly) decremented but
the-object-y-points-to
2. in this example noting will be decremented since y never goes out of
scope. Just by assining y to x you dont "invalidate" y.

Ciao Ulrich






More information about the Python-list mailing list