I'm looking for a simple way to make NaN values output as something
like '-' or even just a space instead of the string 'nan'.  This would
then make it much easier to handle outputting values from sensors when
not all sensors are present. 

So, for example, my battery monitoring program outputs:-

    Battery Voltages and Currents
    Leisure Battery - 12.42 volts  -0.52 Amps
    Starter Battery - 12.34 volts  -0.01 Amps

If the starter battery sensor has failed, or is disconnected, I see:- 

    Battery Voltages and Currents
    Leisure Battery - 12.42 volts  -0.52 Amps
    Starter Battery -   nan volts    nan Amps


What I would like is for those 'nan' strings to be just a '-' or
something similar.

Obviously I can write conditional code to check for float('nan')
values but is there a neater way with any sort of formatting string or
other sort of cleverness?


-- 
Chris Green
ยท
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to