How to copy a ClassObject?
Karlo Lozovina
_karlo_ at _mosor.net_
Tue Mar 20 09:08:58 EDT 2007
Hi all,
how would one make a copy of a class object? Let's say I have:
class First:
name = 'First'
And then I write:
tmp = First
then 'tmp' becomes just a reference to First, so if I write
tmp.name = "Tmp", there goes my First.name. So, how to make 'tmp' a copy
of First, I tried using copy.copy and copy.deepcopy, but that doesn't
work.
P.S.
Yes, I can do a:
class tmp(First):
pass
but I'd rather make a copy than a subclass.
Thanks.
--
_______ Karlo Lozovina - Mosor
| | |.-----.-----. web: http://www.mosor.net || ICQ#: 10667163
| || _ | _ | Parce mihi domine quia Dalmata sum.
|__|_|__||_____|_____|
More information about the Python-list
mailing list