A = X > Y ? X : Y
effbot at telia.com
Wed Feb 9 19:47:15 CET 2000
Justin Sheehy <dworkin at ccs.neu.edu> wrote:
> > Why not just use the max method?
> > a = max(x,y)
> Well, the original poster's question was for something equivalent to
> their use of C's ?: ternary operator. max() is not equivalent to that.
umm. to be precise, he asked for something equivalent to
"the C command a = x > y ? x : y". I'd say "a = max(x, y)"
is a pretty good approximation ;-)
(sure, the x and y *names* are both evaluated, but they're
references, and the corresponding objects are not affected
in any way...)
More information about the Python-list