i++ in Python?

David Eppstein eppstein at ics.uci.edu
Thu Jul 18 18:56:08 EDT 2002


In article <5606b639.0207181429.2c6d2569 at posting.google.com>,
 otis_usenet at yahoo.com (OtisUsenet) wrote:

> Python newbie question.  How does one do something like this in
> Python:
> 
>     # assign the value of j to i and then increment j by 1
>     i = j++

Python is not designed for maximal terseness, nor for compatibility with 
C, so you need two statements to do this (well, maybe there's a way to 
do it in one, but the easiest-to-read and therefore best is with two):

      i = j
      j += 1

-- 
David Eppstein       UC Irvine Dept. of Information & Computer Science
eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/



More information about the Python-list mailing list