Decimal() instead of float?

Michael B. Trausch fd0man at
Sun Nov 12 02:23:24 CET 2006

Is there a way to use Decimal() by default in Python instead of float?
I've no use for the float type, and I have some stuff that would require
Decimal(), but it is kind of a pain to try and cast things all over the
place all the time.  Float is just way too inexact for me.

I am searching around, and I don't see anything helpful, but I could (as
always) be missing something... I tried (rather naïvely) to just do
something like:

>>> import decimal
>>> float=Decimal
>>> x=1.1
>>> x

But, that didn't work (obviously).  It was a shot, anyway.  Are there
any ideas, or does anyone have a way around this?  I would prefer to not
have to convert incoming floating point numbers to strings and then
convert them to Decimal() types every single time that I want to use
them (which would be in *every* case).  For example, I have a ZIP code
database that can do some processing on its numbers, and the numbers are
stored as floating point values (exactly) but Python doesn't get them
right; so the Decimal() thing would be needed.  *shrugs*

    Thanks a bunch,

Michael B. Trausch
                    fd0man at
Phone: (404) 592-5746
   Jabber IM: fd0man at

Demand Freedom!  Use open and free protocols, standards, and software!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list