[Tutor] Independent class instances

Runsun Pan runsun@bilbo.bio.purdue.edu
Wed Nov 27 11:55:06 2002


Hi all,

I have some class, say, myFont. I'm trying to make different
instances outta it:

f1 = myFont()
f1.color = 'red'

f2 = f1
f2.color = 'black'

When I assign 'black' to f2.color, f1.color changed to 'black' too.
This is not what I want.

Is there anyway to 'copy' entire content of a class to a new 
instance ?

I can make something like:

f3 = myFont()
f3.color = f1.color

This way, changing f3.color won't change f1.color. But it would become 
tedious if I have to manually 'copy' each attributes, especiall if this
class have like 20 attributes.

Thx in advance for any help.

pan





-- 
 ========================================
 --->  Be like water, be shapeless   <---

 Runsun Pan, PhD 
 Ecology & Evolution, U. of Chicago
 ========================================