More On - deepcopy, Tkinter

Duncan Booth duncan.booth at invalid.invalid
Tue Jul 5 10:25:36 EDT 2005


phil wrote:

> It is frustrating to think that in a language like python
> there might be things which you can't make a copy of.
> That is bizarre enough to wonder about a deep flaw or
> hopefully I'm just doing something very wrong.

To be honest, it doesn't really surprise me that you cannot copy Tkinter 
objects. If you could make a copy of an object which is displayed on the 
screen I would expect that copying would create another object on the 
screen, and that probably isn't what you want. Other uncopyable objects 
include files, stack frames and so on.

The deepcopy protocol does allow you to specify how complicated objects 
should be copied. Try defining __deepcopy__() in your objects to just copy 
the reference to the Canvas object instead of the object itself.




More information about the Python-list mailing list