math module for Decimals
dickinsm at gmail.com
Sun Dec 28 15:38:32 CET 2008
On Dec 28, 7:28 am, Steven D'Aprano <st... at REMOVE-THIS-
> Ah crap, I forgot that from_float() has been left out of the decimal API.
> That's very annoying.
Agreed. It's maybe even annoying enough that a feature request
at bugs.python.org might be honoured. (Hint, hint!)
It's fairly easy to emulate in Python 2.6 and above, using the
as_integer_ratio float method:
>>> from decimal import Decimal
>>> from math import pi
>>> n, d = pi.as_integer_ratio()
More information about the Python-list