John Roth wrote:

"praba kar" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]


Dear All,
   I am new to Python.  I want to know how to
work with ternary operator in Python.  I cannot
find any ternary operator in Python.  So Kindly
clear my doubt regarding this


There isn't one, and there won't be one unless Guido
changes his mind, and that's quite unlikely.

Au contraire, mon frere:

There is a ternary operator in Python (fairly ill-documented)
Its name is "partial polynomial eval."  As is traditional in
implementing ternary operations in computer languages, the
name of the operator does not show up anywhere in the code,
so many people don't realize they are using it.  Here is an
example of the "ppe" used to evaluate a cubic, using the
ternary operator three times in a single statement:

    def cubic(x, a, b, c, d):
        return ((a * x + b) * x + c) * x + d

As you may be able to guess, the more common name is "*+",
and it is a nice self-documenting operator (it behaves just
like the primitives).  Originally the DEC Vax provided this
as a "vectorized" opcode, which is where Python got the
idea.  You probably don't see it since you aren't doing much
engineering work.

--Scott David Daniels
[EMAIL PROTECTED]

-- No truth has been harmed by this April Fool's post. :-)
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to