Multiple operators between operands

python

Solution

You can use `dis` here to see how the expression was actually evaluated:

In [29]: def func():
   ....:     return 5 -+-+-+ 2
   ....: 

In [30]: import dis

In [31]: dis.dis(func)
  2           0 LOAD_CONST               1 (5)
              3 LOAD_CONST               2 (2)
              6 UNARY_POSITIVE      
              7 UNARY_NEGATIVE      
              8 UNARY_POSITIVE      
              9 UNARY_NEGATIVE      
             10 UNARY_POSITIVE      
             11 BINARY_SUBTRACT     
             12 RETURN_VALUE        

So that expression is equivalent to this:

In [32]: 5 - (+(-(+(-(+(2))))))
Out[32]: 3

Problem

Can someone explain why the Python interpreter (2.7.3) gives the following: ``` >>> 5 -+-+-+ 2 3 ``` Is this ever useful, and for what purpose?

Original source