Proposal: Decimal literals in Python.
J. Cliff Dyer
jcd at sdf.lonestar.org
Fri Oct 26 19:29:47 EDT 2007
Ben Finney wrote:
> Matimus <mccredie at gmail.com> writes:
>
>
>> The trailing L [for 'long' literals] is going away in Python 3.0.
>>
>
> Yes. On the other hand, we are gaining '0bNNNN' for binary literals,
> to go along with '0oNNNN' for octal and '0xNNNN' for hexadecimal.
>
> So, the original poster might get further by proposing an '0dNNN.NNN'
> syntax for 'decimal.Decimal' literals.
It would rather be remarkably inconsistent and confusing.
Python 3.0a1 (py3k:57844, Aug 31 2007, 16:54:27) [MSC v.1310 32 bit
(Intel)] on win32
<snip>
>>> type(0b1)
<type 'int'>
>>> type(0o1)
<type 'int'>
>>> type(0x1)
<type 'int'>
>>> assert 0b1 is 0x1
>>>
<hypothetical code>
>>> type(0d1)
<class 'decimal.Decimal'>
>>> assert 0b1 is 0d1
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
assert 0b1 is 0d1
AssertionError
</hypothetical code>
It would also be unkind to people with dyslexia.
Cheers,
Cliff
More information about the Python-list
mailing list