[Tutor] constructors

Karthik Gurumurthy karthikg@aztec.soft.net
Wed, 10 Apr 2002 11:58:00 +0530


Hi Erik,

> and sometimes I use this class to pull an already-existing Person's

coming from a java background, there is a concept of cloning to do the
copying part.
I guess it's there in most OO languages ( i guess it the copy constructor in
C++ ?? and so on...)
It c'd be as simple as having a method clone() on your Person class to do
it, the way it is in java.
It just fills up another instance with the current Person's attributes and
w'd return that.

typically used as

 p1 = person(name="abc")
 p2 = p1.clone()

am not sure if this is considered a good practice in Python too.

regards,
karthik.




_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor