Decimals

Tgone bapolis at gmail.com
Tue Jun 13 05:46:35 EDT 2006


Sybren Stuvel wrote:
> Tgone enlightened us with:
> > Sorry, when I print out the variable it displays as '15.0'. The
> > price is '15.00' in the database though.
>
> That's the same thing, isn't it? 15.0 == 15.000000000

Yes, they're both mathematically the same. I never said they weren't...

> > Here's my code:
> >
> > product = Product.get(2)
> > print product.price # 15.0
>
> Try string formatting:
>
> print '%.2f' % product.price

That works. I expected Python to display the data exactly as it is in
the database, like most languages.




More information about the Python-list mailing list