Laszlo Nagy wrote: > 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?
Sorry, when I print out the variable it displays as '15.0'. The price is '15.00' in the database though. Here's my code: product = Product.get(2) print product.price # 15.0 I'm using MySQLdb if that helps. -- http://mail.python.org/mailman/listinfo/python-list