On Mon, Mar 10, 2014 at 12:12 PM, Oscar Benjamin <oscar.j.benjamin@gmail.com> wrote:
On 10 March 2014 10:59, Steven D'Aprano <steve@pearwood.info> wrote:
> On Mon, Mar 10, 2014 at 10:07:11AM +0000, Oscar Benjamin wrote:
>> On 9 March 2014 20:39, Guido van Rossum <guido@python.org> wrote:
>> > On Sun, Mar 9, 2014 at 1:07 PM, Oscar Benjamin <oscar.j.benjamin@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.
>
> Is that still true? Possibly the peephole optimizer has changed the
> situation?

Yes it does. It also does the same for "complex literals" even though
the language formally only defines imaginary literals.

... and don't forget the Python 2.x-only hack for negation of integers:

>>> type(-9223372036854775808)

<type 'int'>

>>> type(-(9223372036854775808))

<type 'long'>


which means that it's not true that Python 2.x behaves "as if" there were no negative literals.  Python 3 is cleaner in this respect.  I guess this shows that we *could* in theory reintroduce such a hack for negation of decimal literals, but I agree with everyone else so far that that would be a bad idea.

-- 
Mark