Ticket #506 (closed: fixed)

Opened 12 years ago

Last modified 5 years ago

Investigate problem with scoping in Python scripts running inside MantidPlot

Reported by: Martyn Gigg Owned by: Martyn Gigg
Priority: major Milestone: Iteration 16
Component: Keywords:
Cc: Blocked By:
Blocking: Tester:

Description

The following code runs perfectly fine in a stand-alone Python editor but it fails with a name error when run through MantidPlot

import re

def myfunc():

re.compile('regex') print 'done'

myfunc()

Change History

comment:1 Changed 12 years ago by Martyn Gigg

(In [2292]) Fixed issues with scoping with Python and MantidPlot. All function definitions are now applied to the main global dictionary rather than the local one. Imported scripts that contain mantid commands will need to import the simple API separately since external scripts maintain a separate global dictionary. Re #506

comment:2 Changed 12 years ago by Martyn Gigg

(In [2294]) The Python API now adds both the current directory and the scripts directory to its search path. There is a new property in Mantid.properties that indicates the location of the scripts directory. The default is set to the path for the installed layout on Windows machines. Re #506

comment:3 Changed 12 years ago by Martyn Gigg

(In [2298]) Ensure that all sub-directories of the scripts directory are added as Python search paths. Re #506

comment:4 Changed 12 years ago by Martyn Gigg

(In [2305]) This should fix Python scripting and the import search path. Re #506

comment:5 Changed 11 years ago by Martyn Gigg

  • Status changed from new to closed
  • Resolution set to fixed

comment:6 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 1354

Note: See TracTickets for help on using tickets.