Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Python
Ternary Operator in Python
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Scott David Daniels, post: 1812739"] 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]Scott.Daniels@Acm.Org[/email] -- No truth has been harmed by this April Fool's post. :-) [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Python
Ternary Operator in Python
Top