Instance at two addresses (Python 2.2)?
Kevin Smith
Kevin.Smith at sas.com
Fri Jan 24 11:18:52 EST 2003
I have a program that creates a large object consisting of nested lists.
I then cache certain instances (which correspond to sections) of that
object into a smaller list. Then I process the document in various ways
using the smaller list to jump to the sections in the large object.
This worked fine in Python 2.0, but doesn't in Python 2.2. Here is a
simplified version of the offending code:
def sectionsBefore(self):
""" Return a list of sections that occur before 'self' in the
document """
list = []
# Walk through cached document sections list
for section in self.documentSections():
#
# 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:
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?
--
Kevin Smith
Kevin.Smith at sas.com
More information about the Python-list
mailing list