python - Multiple operators between operands -


can explain why python interpreter (2.7.3) gives following:

>>> 5 -+-+-+ 2  3 

is ever useful, , purpose?

you can use dis here see how expression 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 expression equivalent this:

in [32]: 5 - (+(-(+(-(+(2)))))) out[32]: 3 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -