Musings about Python syntax

Tim Peters tim_one at email.msn.com
Tue Oct 19 21:47:01 EDT 1999


[steve_allison at my-deja.com]
> I've been working through the Python tutorial, and a have a few queries
> about the syntax of Python.  Python seems to me to basically be a very
> nicely constructed language, but I have been wondering about a few
> (seeming) syntactic anomalies:
>
> i) if Python is as object orientated as is claimed,

As claimed by whom?  Python is a mix of procedural and OO constructs, with a
dash of functional constructs tossed in just to keep the flame level high
<0.9 wink>.  Purists of any stripe will find something to be annoyed about
here.

> ...
> ii) similarly, why is 'del' operator like, and not a member function of
> those types that support it ?  having an 'append' method, but a 'del'
> operator seems peculiar.

"del" isn't an operator, though, it's a statement, used to "remove things"
in general:  it can remove local name bindings, zap slices out of the middle
of sequences, and purge associations from mapping objects.  list.pop() is
the inverse of list.append(x), BTW, and list.pop(i) the inverse of
list.insert(i, x).  If the use of del bothers you for sequences, you can
always write e.g. "seq[i:j] = []" instead of "del seq[i:j]" -- but your code
will be harder for everyone else (including the future Mr. Allison <wink>)
to follow.

> ...
> have mostly really liked what I've seen of Python so far, but niggles
> like these are really annoying me!

The good news is you'll get over that -- or you won't.

self-resolving-either-way-ly y'rs  - tim






More information about the Python-list mailing list