A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2004-July/045880.html below:

[Python-Dev] decimal API

[Python-Dev] decimal APIBatista, Facundo FBatista at uniFON.com.ar
Mon Jul 5 19:41:37 CEST 2004
[Raymond Hettinger]

#- So, my question for the group is whether to:
#- 
#- * leave it as-is
#- * raise a ValueError just like float('abc') or int('abc')
#- * raise an Invalid Operation and return a quiet NaN.

I'll go for leaving it as-is:

>>> import Decimal
>>> d = Decimal.Decimal('rdd')
>>> d
Decimal("NaN")
>>> Decimal.getcontext().trap_enablers[Decimal.ConversionSyntax] = True
>>> d = Decimal.Decimal('rdd')
Traceback (most recent call last):
  File "<pyshell#6>", line 1, in ?
    d = Decimal.Decimal('rdd')
  File "D:\Facundo\python\Decimal.py", line 445, in __init__
    >>> Decimal(314)                 # int or long
  File "D:\Facundo\python\Decimal.py", line 594, in _convertString
    return self._int != (0,)*len(self._int)
  File "D:\Facundo\python\Decimal.py", line 2167, in _raise_error
ConversionSyntax

If you want an exception, you got it easily.

.	Facundo

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.713 / Virus Database: 469 - Release Date: 30/06/2004
 

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4