Instance at two addresses (Python 2.2)?

Kevin Smith Kevin.Smith at
Sat Jan 25 18:48:02 CET 2003

In <RXednVAHO9BqVKyjXTWcqg at> Terry Reedy wrote:
>> # This 'if' block works in Python 2.0, but not in Python 2.2.
>> # For some reason, in Python 2.2, 'self' isn't equivalent to
> 'section'
>> # at any point even though they appear to point to the same object
>> # based on other criteria (i.e. result of calling other methods).
>>          # If 'self' is the same object as 'section', then break
>>          # out and return the current list of sections.
>>          if section is self:
> Have you verified that this is true (in 2.2) on creation of the
> instance where this is not true.  Is the problem with just one or some
> instances or all?  Does output of documentSections() stay constant?

It appears to happen to all instances except the root node of the 
document.  The result of documentSections() is always constant.  It 
creates the list of sections on its first call and stores it, and every 
call thereafter returns the stored version. 
>>             list.reverse()
>>             return list
>>          # Keep looking.
>>          else:
>>             list.append(i)
>>       list.reverse()
>>       return list
>> Does anyone know what occurred in Python 2.2 to make this not work
>> anymore?
> My suggestion: explore some more with print statements (or the
> debugger) to isolate when mismatch is first apparent.

It's going to take a while to really track it down.  This is a pretty 
large program.  I did do one more thing though.  On instantiation of 
each node in the document I saved the result of 'id(self)' in an 
instance variable and compared that to the same 'id(self)' in the code 
above.  These two calls give different answers (except on the root node).  
I'll keep trying to track it down, but at least I can use this new 
instance variable as a workaround for now.

Kevin Smith
Kevin.Smith at

More information about the Python-list mailing list