In article <[EMAIL PROTECTED]>, Peter Hansen <[EMAIL PROTECTED]> wrote: >Alan Morgan wrote: >> Right. I was wondering what would happen in this case: >> >> s=[1,2,3] >> t=s >> s.clear() >> t # [] or [1,2,3]?? >> >> If you know your basic python it is "obvious" what would happen >> if you do s=[] or s[:]=[] instead of s.clear() and I guess it is >> equally "obvious" which one s.clear() must mimic. I'm still not >> used to dealing with mutable lists. > >If you know your basic python :-), you know that s[:] = [] is doing the >only thing that s.clear() could possibly do,
Ah, but if you know your basic python then you wouldn't be looking for s.clear() in the first place; you'd just use s[:]=[] (or s=[], whichever is appropriate). IOW, the people most in need of s.clear() are those least likely to be able to work out what it is actually doing. Personally, it seems more *reasonable* to me, a novice python user, for s.clear() to behave like s=[] (or, perhaps, for s=[] and s[:]=[] to mean the same thing). The fact that it can't might be an argument for not having it in the first place. Alan -- Defendit numerus -- http://mail.python.org/mailman/listinfo/python-list