Python ++ Operator?

Chris Angelico rosuav at gmail.com
Fri Jul 15 18:51:34 EDT 2011


On Sat, Jul 16, 2011 at 6:26 AM, Dan Stromberg <drsalists at gmail.com> wrote:
>
> I don't regard this as a low level versus VHLL issue - I regard it as a
> matter of operators with side effects being too error prone.  Adding such
> operators to Python has been discussed (it'd almost certainly be easy to
> add), and rejected.

It's not that it has or has not, due to its highness of level, but
more a needs or needs not. In Python, iterating over an array is done
with a for loop and the array's own iterator (or enumerate() if you
need the indices), but C doesn't have iterators, so it needs a
convenient notation for incrementing through the array.

> BTW, array operations optimize to the same thing as pointer arithmetic in
> most C compilers, but the latter tends to be less clear.

I'm not fully convinced; there are many times when incrementing
pointers allows for much cleaner code. However, we are talking about
the readability of C among Python programmers. Personally, I find
pointer-dereference-and-post-increment to be perfectly readable, but
it's a construct that I use practically on a daily basis. To someone
who's not familiar with Python, list comps could suffer from the same
issues - what does THIS do? oh.

Chris Angelico



More information about the Python-list mailing list