[Python-ideas] Python Numbers as Human Concept Decimal System

Mark Dickinson dickinsm at gmail.com
Mon Mar 10 09:32:16 CET 2014


On Sun, Mar 9, 2014 at 8:07 PM, Oscar Benjamin
<oscar.j.benjamin at gmail.com>wrote:

> The problem though is with things like +3.14d or -3.14d. Python the
> language treats the + and - signs as not being part of the literal but
> as separate unary operators. This is unimportant for int, float and
> imaginary literals because there unary + is a no-op and unary - is
> exact. For decimal this is not the same as +Decimal('3.14') is not the
> same as Decimal('+3.14'):
>

Another option would be to change the behaviour of + and - on Decimal
objects by binding `__pos__` and `__neg__` to the specification's 'copy'
and 'copy-negate' operations instead of (as currently) to the 'plus' and
'minus' operations.  Those behaviours are more in keeping with the way that
+ and - operate on other objects.

-- 
Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140310/565967ec/attachment-0001.html>


More information about the Python-ideas mailing list