Workbench Python bugs

Two bugs/features in Workbench 4.1:

  1. If I have a “for” loop in a script, the green progress arrow in the margin goes straight to the first line after the loop, as soon as the loop is entered. It ought to work as in MantidPlot where the arrow indicates progress within the loop.

  2. The “from future import print_function” for Python 3 preparations isn’t working as advertised. If I use print (“the answer is”,x) I get a tuple in the messages window such as (‘the answer is’,42.0). It’s as if the future statement is used for syntax checking, rejecting bare print statements, but then turns itself off.

To follow up, this works under standard Python 2.x, even using …/MantidInstall/bin/python.exe, but NOT in Workbench (gives a syntax error):

from __future__ import print_function
myprint ( "the answer is", 42 )

And it appears the other __ future__ statements are broken too.

“division” doesn’t make 1/3 return 0.33333 (it’s still integer 0 as in plain Python 2.7).

unicode_literals is broken too. String literals are not Unicode unless I add the “u” prefix. If I attempt to save a script with a non-ascii character in a string literal, such as £ (with or without a source code encoding indicator as in PEP263) I get an error traceback indicating it was trying to use ascii encoding and the error reporting dialog. And if I put in the encoding indicator and then try to run the (unsaved) script I get a syntax error.

I’ve not yet devised a simple test for “absolute_import”…

An issue has been created for this: