Python ++ Operator?

Dan Stromberg drsalists at gmail.com
Fri Jul 15 16:26:56 EDT 2011


On Fri, Jul 15, 2011 at 1:06 AM, Chris Angelico <rosuav at gmail.com> wrote:

> 2011/7/15 Björn Lindqvist <bjourne at gmail.com>:
> > Pre and post-increments are
> > almost always confusing unless they are used as the counter-variable
> > inside for-loops.
>
> I agree that they're often confusing (i+++++j) but there are several
> places where they're handy.
>
> array[count++]=value;
>
> or the more direct pointer management:
>
> *ptr++=value;
>
> However, Python doesn't work as close to the bare metal, so it doesn't
> have such constructs.
>

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.

BTW, array operations optimize to the same thing as pointer arithmetic in
most C compilers, but the latter tends to be less clear.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110715/bfc7293f/attachment-0001.html>


More information about the Python-list mailing list