Tim Wintle wrote:
On Fri, 2009-04-03 at 13:12 -0400, Mel wrote:
I think it would also be better to have One (and prefereably Only One)
Obvious Way To Do It. That obvious way, for those who work with
Python's ‘set’ and ‘dict’, is a ‘clear’ method. It seems best to have
‘list’ conform with this also.
Does that mean a one-off special case rule to forbid slices having a
default?
Why would it do that?
Well, if list.clear were truly and strictly to be the only way to clear the contents of a list, then assigning nothing via the default slice would have to be ruled out. `somelist[:] = []` is just a special case of assignment to a slice generally.

agreed. If .clear was to be added then really assignments to slices
should be entirely removed.
Should we also remove .update from dict?

I see no problem in collections having a .clear method. Saying that "if
c is a collection then c.clear() clears that collection" seems to be a
very duck-typy(?) thing to me.

Assignments to slices is just a feature of ordered collections (well,
lists), and clearing a list by assigning an empty list is just a special
case of that.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to