Re: Copy an Object (Again?)

2006-01-07 Thread Alex Martelli
KraftDiner <[EMAIL PROTECTED]> wrote: ... > objs = myListOfObjects > for obj in objs: >if obj.flag: > newObject = copy.deepcopy(obj) > newObject.mirror() > myListOfObjects.append(newObject) Never modify the very list you're looping on. I doubt this is the root of your pro

Re: Copy an Object (Again?)

2006-01-06 Thread Schüle Daniel
I was not very clear about it > or even if you "could" copy instances > > class X: > def __init__(self, filename = "/path/file") > self.file = file(filename, "w+") > def modifyByteAt(offset): > self.file.tell(offset) > self.file.write("X") > > this is untested pse

Re: Copy an Object (Again?)

2006-01-06 Thread Ernst Noch
KraftDiner wrote: > I'm having trouble getting a copy of and object... (a deep copy) > > I'm writing a method that creates a mirror image of an object (on > screen) > In order to do this i need to get a copy of the object and then modify > some > of its attributes. > > I tried: > objs = myListOfO

Re: Copy an Object (Again?)

2006-01-06 Thread Schüle Daniel
KraftDiner wrote: > I'm having trouble getting a copy of and object... (a deep copy) > > I'm writing a method that creates a mirror image of an object (on > screen) > In order to do this i need to get a copy of the object and then modify > some > of its attributes. > > I tried: > objs = myListOfO

Copy an Object (Again?)

2006-01-06 Thread KraftDiner
I'm having trouble getting a copy of and object... (a deep copy) I'm writing a method that creates a mirror image of an object (on screen) In order to do this i need to get a copy of the object and then modify some of its attributes. I tried: objs = myListOfObjects for obj in objs: if obj.flag