else on the same line - howto

David Eppstein eppstein at ics.uci.edu
Wed Oct 15 12:20:50 EDT 2003


In article <mailman.114.1066216686.2192.python-list at python.org>,
 Gerrit Holl <gerrit at nl.linux.org> wrote:

> > Since Python lacks conditional expression
> > 
> > like
> > 
> > k+= (dy >= 0 ? 1 : -1)

k += 2*(dy >= 0) - 1

-- 
David Eppstein                      http://www.ics.uci.edu/~eppstein/
Univ. of California, Irvine, School of Information & Computer Science




More information about the Python-list mailing list