always the same object (2)
Uwe Mayer
merkosh at hadiko.de
Tue Jan 20 19:14:51 EST 2004
Hi,
sorry for the lack of source code.
Here again:
I use struct.unpack() to unpack data from a binary file and pass the
returned tuple as parameter to __init__ of a class that's supposed to
handle the data:
class DataWrapper():
data = { }
def __init__(self, arg): #arg will contain a tuple
data['var1'], data['var2'] = arg
result = [ ]
while not <end-of-file f>:
data = struc.unpack("4s4s", f.read(8))
record = DataWrapper( data ) # pass tuple from unpack
result.append( record )
Then "result" contains a list with different objects, but the strings
in data['var1'] and data['var2'] are all the same.
Any ideas how to avoid this?
Thanks again
Ciao
Uwe
More information about the Python-list
mailing list