Quick shallow-copy idiom

paulhankin paul.hankin at gmail.com
Wed Sep 19 12:04:37 EDT 2007


On Sep 19, 10:48 am, Lawrence D'Oliveiro <l... at geek-
central.gen.new_zealand> wrote:
> y = type(x)(x)

Nice trick, but is it better than the explicit:
 y = copy.copy(x)

(I think not, because copy.copy works for example, on classes
which take more than one argument to their constructor).

--
Paul Hankin




More information about the Python-list mailing list