[Tutor] Object references and garbage collection confusion

Brandon D brwarhol at gmail.com
Tue May 5 06:29:59 CEST 2015


Hello tutors,

I'm having trouble understanding, as well as visualizing, how object
references work in the following situation.  For demonstration purposes I
will keep it at the most rudimentary level:

x = 10

x = x ** x

If my knowledge serves me correctly, Python destroys the value once
reassigned.  So, how does x = x +  1 work if it's destroyed before it can
be referenced?  The only solution I came up with is that the two operands
are evaluated before storing it in the variable, consequently replacing the
original value of 0.


More information about the Tutor mailing list