Question about idioms for clearing a list

Ed Singleton singletoned at gmail.com
Tue Feb 7 09:08:56 EST 2006


On 7 Feb 2006 02:02:42 -0800, Ben Sizer <kylotan at gmail.com> wrote:
> > Fred is exactly correct.  Slicing is absolutely basic to Python.
> > Accordingly, it gets covered right at the beginning of the tutorial
> > (section 3.1).
>
> Yes, right after UTF encoding details, complex numbers, and various
> mentions of shell scripts.

Now that is GPotD (Good Point of the Day) which is much better than
QotW as it's actually useful.

> I don't want to criticise the hard work that
> went into making the tutorial but let's not pretend it's the epitome of
> documentation or even necessary the most obvious reference for users.
>
> > Likewise, the del keyword is fundamental -- if you
> > can't get, set, and del, then you need to go back to collections
> > school.
>
> I have hardly used the del keyword in several years of coding in
> Python. Why should it magically spring to mind in this occasion?
> Similarly I hardly ever find myself using slices, never mind in a
> mutable context.
>
> del L[:] is not obvious, especially given the existence of clear() in
> dictionaries. I'm not necessarily requesting a clear() method, but I am
> requesting a little more understanding towards those who expected one.
> The list interface is full of redundant convenience methods, so one
> more would hardly be a surprise or an unreasonable thing for people to
> expect. Again we unfortunately have a bit of an attitude problem
> towards anyone posting here that doesn't know whatever the experts
> think is obvious.

I agree wholeheartedly with this, particularly as there often seems to
be strong (and confusing) resistance to making Python easier and more
obvious.  I can only assume that it is by people who have forgotten
what it is like to be an average programmer.  (Paul Graham constantly
makes the same mistake when he goes on about how everyone should use
lisp).

Ed



More information about the Python-list mailing list