Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Quick shallow-copy idiom

Thread Tools

Quick shallow-copy idiom

Lawrence D'Oliveiro
Posts: n/a
y = type(x)(x)
Reply With Quote
Posts: n/a
On Sep 19, 10:48 am, Lawrence D'Oliveiro <l...@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

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding quick-release to a non-quick-release tripod head Digital Photography 4 11-20-2006 03:19 PM
Quick question, hopefully quick answer. ~misfit~ NZ Computing 114 01-06-2005 01:36 PM
Quick Question Quick Answer JKop C++ 11 05-24-2004 09:46 PM
Quick Restore for a Compaq not so quick! Croos Bustamunky Computer Support 2 05-15-2004 04:17 AM
PanasonicBQ390 "quick" charger - How quick? Ol' Bab Digital Photography 1 01-17-2004 06:54 AM