Decimals

Diez B. Roggisch deets at nospam.web.de
Tue Jun 13 12:49:01 EDT 2006


Tgone wrote:

> 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.

Care to give us an example of "one of those"? 

Diez



More information about the Python-list mailing list