[IronPython] prefix postfix bug
dinov at exchange.microsoft.com
Thu Jun 8 04:33:16 CEST 2006
Have you tried this in Cpython? ++ doesn't exist in Python. So what you're really doing is:
print a + (+(+(+(+b))))
Yep, b sure is positive!
and ++b is the same thing +(+b)
and a++ of course makes no sense, because there's no right hand side to the plus operator.
This might make more sense if you replace b with a number, like 1, where might almost occasionally expect the + operator to be used in front of it, for some reason.
Results from CPython:
>>> a =2 ; b = 6
>>> print a++ + ++b
>>> print ++b
>>> print a++
File "<stdin>", line 1
SyntaxError: invalid syntax
>>> import sys
'2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)]'
From: users-bounces at lists.ironpython.com On Behalf Of kurtharriger at comcast.net
Sent: Wednesday, June 07, 2006 7:21 PM
To: users at lists.ironpython.com
Subject: [IronPython] prefix postfix bug
a = 2; b=6;
print a++ + ++b #prints 8
print ++b #prints 6
print a++ #syntax error (at least when using console)
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 6063 bytes
Desc: not available
More information about the Ironpython-users