What is the equivalent in python of the expression below?
EE_DOUBLE const yplus = ( y < 1.0 ) ? y*u_tau/nu_inf : (2.0-y)*u_tau/nu_inf
Any suggestions are welcome. Many thanks A
What is the equivalent in python of the expression below?
EE_DOUBLE const yplus = ( y < 1.0 ) ? y*u_tau/nu_inf : (2.0-y)*u_tau/nu_inf
Any suggestions are welcome. Many thanks A
I'm not too sure about C syntax anymore, but i guess it'll look like this :
yplus = y*u_tau/nu_inf if ( y < 1.0 ) else (2.0-y)*u_tau/nu_inf
yplus = ((2.0-y)*u_tau/nu_inf, y*u_tau/nu_inf)[y < 1.0]
other way
yplus = (y < 1.0) and (y*u_tau/nu_inf) or ((2.0-y)*u_tau/nu_inf)
other way
yplus = {True: y*u_tau/nu_inf, False: (2.0-y)*u_tau/nu_inf} [y < 1.0]
other way marked already by others
yplus = (y*u_tau)/nu_inf if y < 1.0 else (2.0-y)*u_tau/nu_inf
other way
if (y < 1.0):
yplus = (y*u_tau)/nu_inf
else:
yplus = (2.0-y)*u_tau/nu_inf
Using Python's ternary operator added since 2.5
yplus = (y*u_tau)/nu_inf if y < 1.0 else (2.0-y)*u_tau/nu_inf