if expression source format
Duncan Booth
duncan.booth at invalid.invalid
Thu Dec 11 03:11:02 EST 2008
"Lambert, David W (S&T)" <LambertDW at Corning.com> wrote:
>
> The "if" expression leads to long statements. Please offer suggestions
> to beautify this function. For this example use maximum line length
> marked by the ####'s.
>
> Thank you.
>
>
> ##############################################################
> def compute_wind_chill_temperture(T:'Temperature, dF',s:'Wind speed,
> mph')->'dF':
> '''
> <http://www.erh.noaa.gov/er/iln/tables.htm#heat index>
> '''
> return 35.74 + 0.6215*T + s**0.16*(T*0.4275-35.75) if T < 40 else T
If the expression is too long for your liking then just don't use the an if
expression:
if T < 40:
return whatever
else:
return T
is probably easier to read.
More information about the Python-list
mailing list