Yuv Gre <ubershme...@gmail.com> added the comment:
Now that we're on the subject of "from_float", I just recalled this slight
issue:
Python 3.1.2 (r312:79149, Mar 21 2010, 00:41:52) [MSC v.1500 32 bit (Intel)]
on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import decimal
>>> x = decimal.Decimal()
>>> decimal.Decimal.from_float(x)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python31\lib\decimal.py", line 687, in from_float
n, d = abs(f).as_integer_ratio()
AttributeError: 'Decimal' object has no attribute 'as_integer_ratio'
>>>
It seems from_float doesn't like it when a Decimal arrives. Personally, I
think there should be an idiomatic way of saying "this number must be a
Decimal" without an "isinstance".
Should I open another ticket?
----------
Added file: http://bugs.python.org/file17831/unnamed
_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue9136>
_______________________________________
<div dir="ltr">Now that we're on the subject of "from_float", I
just recalled this slight issue:<div><br></div><div><div>Python 3.1.2
(r312:79149, Mar 21 2010, 00:41:52) [MSC v.1500 32 bit (Intel)] on</div><div>
win32</div><div>Type "help", "copyright",
"credits" or "license" for more
information.</div><div>>>></div><div>>>> import
decimal</div><div>>>> x = decimal.Decimal()</div>
<div>>>> decimal.Decimal.from_float(x)</div><div>Traceback (most
recent call last):</div><div>Â Â File "<stdin>", line 1, in
<module></div><div>Â Â File "C:\Python31\lib\decimal.py", line
687, in from_float</div>
<div>Â Â Â n, d = abs(f).as_integer_ratio()</div><div>AttributeError:
'Decimal' object has no attribute
'as_integer_ratio'</div><div>>>></div></div><div><br></div><div>It
seems from_float doesn't like it when a Decimal arrives. Personally, I
think there should be an idiomatic way of saying "this number must be a
Decimal" without an "isinstance".</div>
<div><br></div><div>Should I open another ticket?</div></div>
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com