I ask if I can to use a variable condition on PYTHON like PHP :
<?php $var = (5 = 5) ? true : false; ?>
I ask if I can to use a variable condition on PYTHON like PHP :
<?php $var = (5 = 5) ? true : false; ?>
Just assign the result of the boolean test in your case:
var = 5 == 5 # assigns `True`
Otherwise you are looking for a conditional expression:
var = 'bar' if foo == 5 else 'spam'
There's a conditional expression (also known as the ternary operator) in python, if that's what you mean:
me = 5 if a == b else c
I guess you mean:
$var = (5 == 5) ? true : false
In Python (2.5 up) this can be written as:
b if a else c
"First a is evaluated, then either b or c is returned based on the truth value of a; if a evaluates to true b is returned, else c is returned." http://northisup.com/blog/the-ternary-operator-in-python/