-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
scijava/scyjava
#75Labels
bugSomething isn't workingSomething isn't working
Description
As noted by @ian-coccimiglio here, scripts with functions do not inherit imported modules, nor other globals.
This script fails:
import numpy
def version():
return numpy.__version__
print(version())Whereas this script works:
import numpy
def version():
global numpy
return numpy.__version__
print(version())Interestingly, SciJava #@ variables injected into the bindings are put into locals() but not globals(), which means they are inaccessible to functions even when the global keyword is used:
#@ ImageJ ij
print(ij)
print(f"-- Globals? {'ij' in globals()}")
print(f"-- Locals? {'ij' in locals()}")
print(f"-- Dir? {'ij' in dir()}")yields:
plugin:net.imagej.ImageJ
-- Globals? False
-- Locals? True
-- Dir? True
So there are maybe two different bugs going on here?
karlduderstadtian-coccimiglio
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working