Decimals

Laszlo Nagy gandalf at designaproduct.biz
Tue Jun 13 05:09:39 EDT 2006


Tgone írta:
> Hello,
>
> I have a price column in a MySQL table: price decimal(5,2)
>
> When I access them in Python with SQLObject, prices display as 15.0
> instead of 15.00. Why is this happening? I can't figure out why Python
> is trimming off the hundredth place. I'm not doing any formatting...
>   
What do you mean by 'displays as 15.0'? Do you print in with the print 
statement? If your DB access module returns decimal.Decimal instances, 
then you are right. It should print as 15.00 instead of 15.0. Try to 
determine the type of the returned value. Maybe your DB module uses 
float instead of Decimal?

Best,

   Laszlo




More information about the Python-list mailing list