Python ++ Operator?

Stefan Behnel stefan_ml at behnel.de
Fri Jul 15 17:09:02 EDT 2011


Chris Angelico, 15.07.2011 10:06:
> 2011/7/15 Björn Lindqvist:
>> 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;

More direct, sure. But readable? Well, only when you know what this 
specific pattern does. If you have to think about it, it may end up hurting 
your eyes before you figure it out.

Stefan




More information about the Python-list mailing list