[Nicolas Fleury]
> This comment reminds me another small inconsistency/annoyance.
> 
> Should copy and clear functions be added to lists, to be more
consistent
>   with dict and set, and easing generic code?

I think not.

Use copy.copy() for generic copying -- it works across a wide range of
objects.  Alternatively, use the constructor as generic way to make
duplicates:

   dup = set(s)
   dup = list(l)
   dup = dict(d)
   dup = tuple(t)     # note, the duplicate is original object here :-)

I would think that that generic clearing is a lark.  First, it only
applies to mutable objects.  Second, it would likely only be useful in
the presence of a generic method for adding to the cleared container (as
opposed to the existing append(), add(), and setitem() methods for
lists, sets, and dictionaries respectively).  So, for lists, stick with
the current idiom:

   mylist[:] = []       # clear



Raymond

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to