else on the same line - howto

Helmut Jarausch jarausch at remove.igpm.rwth-aachen.de
Wed Oct 15 06:39:34 EDT 2003


Sorry for this trivial question

Since Python lacks conditional expression

like

k+= (dy >= 0 ? 1 : -1)

I would like to write
if  dy >= 0 : k+= 1; else: k-= 1

instead of
if  dy >= 0 :  k+= 1
else        :  k-= 1

but I don't know the exact syntax for writing
the 'else' clause onto the same line.

Thanks for a hint,

Helmut Jarausch
RWTH-Aachen University
Germany





More information about the Python-list mailing list