[Python-ideas] Have list/deque grow a copy() method

Josiah Carlson jcarlson at uci.edu
Tue May 15 22:47:09 CEST 2007


"Fred L. Drake, Jr." <fdrake at acm.org> wrote:
> 
> On Tuesday 15 May 2007, Steven Bethard wrote:
>  > For builtin container types (and many other container types as well):
>  >     type(obj)(obj)
>  > is another polymorphic way to create copies.
> 
> If you're willing to rely on the constructor signature, sure.  For many 
> applications, the convention that the constructor can be used as a copier 
> doesn't hold.

But for builtin types (which is the only objects we can reliably change),
using the base constructor to copy an object *does* work for all
container types (except for defaultdict).

 - Josiah




More information about the Python-ideas mailing list