I need a neat way to print nothing or a number

cl at isbd.net cl at isbd.net
Tue Mar 26 16:50:11 CET 2013


What's a neat way to print columns of numbers with blanks where a number
is zero or None?

E.g. I want to output something like:-

    Credit      Debit   Description
    100.00              Initial balance
    123.45              Payment for cabbages
                202.00  Telephone bill


For each line I have either the credit or the debit amount and the other
is 0 or None.  However you can't get number formatting (old or new) to
output a blank for 0 and it barfs on None.

-- 
Chris Green



More information about the Python-list mailing list