duplicate of classes (deep copy)

Michel Lesoinne (michel@vette.colorado.edu)
Thu, 23 Sep 93 14:08:45 -0600

I am trying to write a program that uses fcntl.ioctl to change the condition
of a modem line and then at the end reset it to its original value.
Is there a simple function in python of all classes that does a deep
copy of an instance, similarily to dup in smalltalk.
For example I'd like the following to work correctly:

tio = Termio()
tio.getfrom(0) # performs a TCGETA on file 0
oldtio = tio.dup() #Here it is. of course I can write the dup funtion but
# it would be nice if all classes had it so that
#it would recursively apply to members
tio.lflag = 0 ;
tio.iflag = IGNBRK ;
tio.oflag = 0 ;

tio.setto(0) # Change the line

... # do whatever work

oldtio.setto(0) # reset line condition to original value

Thanks for any hints.

Michel