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&#39;re on the subject of &quot;from_float&quot;, 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 &quot;help&quot;, &quot;copyright&quot;, 
&quot;credits&quot; or &quot;license&quot; for more 
information.</div><div>&gt;&gt;&gt;</div><div>&gt;&gt;&gt; import 
decimal</div><div>&gt;&gt;&gt; x = decimal.Decimal()</div>
<div>&gt;&gt;&gt; decimal.Decimal.from_float(x)</div><div>Traceback (most 
recent call last):</div><div>  File &quot;&lt;stdin&gt;&quot;, line 1, in 
&lt;module&gt;</div><div>  File &quot;C:\Python31\lib\decimal.py&quot;, line 
687, in from_float</div>
<div>    n, d = abs(f).as_integer_ratio()</div><div>AttributeError: 
&#39;Decimal&#39; object has no attribute 
&#39;as_integer_ratio&#39;</div><div>&gt;&gt;&gt;</div></div><div><br></div><div>It
 seems from_float doesn&#39;t like it when a Decimal arrives. Personally, I 
think there should be an idiomatic way of saying &quot;this number must be a 
Decimal&quot; without an &quot;isinstance&quot;.</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

Reply via email to