Question about idioms for clearing a list

Magnus Lycka lycka at carmen.se
Wed Feb 8 04:33:46 EST 2006


Ed Singleton wrote:
> I'm a fairly average programmer (better than average compared to my
> immediate colleagues).  I've read every tutorial I can get my hands
> on, but I have no _memory_  of ever coming across the del keyword, let
> alone that it is fundamental to Python, and I have no idea what
> collections school is.  I doubtless have read of it at some point, but
> as no importance has ever been attached to it, I have probably not
> remembered it.
> 
> Similarly, I remember slices simply because they are handy, not
> because I have ever heard of them being fundamental before.

Ok, I can understand that, but I  think that you really understand
that the strength of a programming language such as Python is that
it's like lego bricks. You have some basic pieces, and you can
combine them to into something unique that does what you want.

There are plenty of statements, operators, functions, types, modules
and other things in Python already. I can well imagine that you had
forgotten about del, and that you don't immediately think about slices
when you wonder how to empty a list. It's like when I build lego with
my son. I guess he has around 2000 pieces, and it's not always easy
to spot what you need. It was difficult enough when I was a kid. Now
there are so many different kinds of pieces, shaped to fulfil some
niche usecase.

One thing that I'm sure of is this: Making more kinds of odd-shaped
"pieces", especially prepared to solve the specific problem I'm facing
right now, won't make it easier to understand or use Python in the
long run.

I've used Python for almost 10 years now, and I still learn new
things, and I sometimes come across things that I once new but
had forgotten.

It might work for a while to add a new convenience function as soon
as someone finds that they don't immediately now how to solve a
certain problem. It's my impression that that's pretty much the idea
with PHP. It's not Python though. PHP is only successful in a fairly
narrow (if important) niche, it has failed in getting used outside
its niche, and I assume we'll see a decline in its use one the web
pretty soon, just as it happened with Perl. (Whether RoR, something
Python based or something entirely new will replace it is beyond my
radar screen though.)



More information about the Python-list mailing list