[IronPython] prefix postfix bug
Dino Viehland
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
8
>>> print ++b
6
>>> print a++
File "<stdin>", line 1
print a++
^
SyntaxError: invalid syntax
>>> import sys
>>> sys.version
'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)
- Kurt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 6063 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20060607/06731d79/attachment.bin>
More information about the Ironpython-users
mailing list