Karlo Lozovina schrieb:
> Karlo Lozovina <[EMAIL PROTECTED]> wrote in
> news:[EMAIL PROTECTED]:
>
>
>>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
>
>
> Silly me, posted a question without Googling first ;>. This seems to be
> the answer to my question:
>
> import new
> class First:
> name = 'First'
> tmp = new.classobj('tmp', (First,), {})
>
> After this, tmp is a copy of First, and modifying tmp.name will not affect
> First.name.
>
> P.S.
> If my code is somehow mistaken and might not function properly in all
> cases, please correct me.
>
> Bye,
> klm.
>
Leave out the `new` module and use `type()` (exactly the same call as to
`new.classobj`) to achieve the same effect.
--
http://mail.python.org/mailman/listinfo/python-list