odd problem, most likely stupid one too :-)

Dave Harrison dlharris at mail.usyd.edu.au
Sat Dec 29 02:16:00 EST 2001


Ive written a class named packet, and I have a list on values that I am using to create my packets by passing the values in as I instantiate the classes I am creating.

I do the creation in a for loop,

for item in itemlist:
	PACKET = Packet(item)
	paclist.append(PACKET)

except that when I try to go back through and see the packets in my paclist they are all exactly the same as the final one that I store in the list.
As in I do,

for pac in paclist:
	print pac.getVal()

and I get exactly the same value, despite the fact that I know for sure they are different.

If I getVal as I create the packets I get the correct and unique values, but once stored I get the oddity.

Any ideas ?

Thanks
Dave




More information about the Python-list mailing list