Is there a cleaner and a shorter way to write this conditional in python? -


>>> def accept(d1, d2):     if somefunc(d1,d2) > 32:         h = 1     else:         h = 0     return h 

does python have ternary conditional operator? doesn't give solution case 1 want return value. lambda based solution preferable.

or, perhaps trickier,

return int(somefunc(d1, d2) > 32) 

note int(true) == 1 , int(false) == 0.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

debian - 500 Error upon login into Plesk Admin - auth.php3? -