Whoa! What is this is I see? was RE: [albatross-users] impedance mismatch 1

Michael C. Neel neel at mediapulse.com
Thu Jul 3 00:43:22 EST 2003


Okay, one thing I miss that python doesn't have is the ?: operator.  But
then Matt writes:

"name.index()%2 and 'red' or 'green'".

Which from my quick tests in idle seem to be working like ?:; with the
execption of:

1 and 0 or 2 returns 2 ( 1 ? 0 : 2 would return 0)  Which I can see why
and I could work around that with int(1 and '0' or 2) If I need a0 for a
true value (rare case).

So my question is, is this a hack of python, or can I always expect this
to stay the same across past and new versions of python?  It seems to
work because python will return the last value in a true and statement;
but with 2.2.1 adding bool() , True, and False I'm worried that at some
point expressions will begin to return True or False as is seems like
there is a movement to a true bool type (2.2.1+ still just maps True to
1; False to 0 is looks like).

Mike



More information about the Albatross-users mailing list