R
reubendb
Hello,
I am new to Python. I have the following question / problem.
I have a visualization software with command-line interface (CLI),
which essentially is a Python (v. 2.5) interpreter with functions
added to the global namespace. I would like to keep my own functions
in a separate module and then import that module to the main script
(that will be executed using the CLI interpreter). The problem is, I
cannot access the functions in the global namespace of the main script
from my module. Is there anyway to do that ?
Here is an example of what I meant. The function AddPlot() and
DrawPlots() are added to the global namespace by the software CLI. If
I do this:
mainscript.py:
---------------------------
AddPlot("scatter", "coordinate")
# set other things here
DrawPlots()
it works fine. But I want to be able to do this:
myModule.py:
----------------------
def defaultScatterPlot():
AddPlot("scatter", "coordinate")
#do other things
DrawPlots()
and then in mainscript.py:
---------------------------------------
import myModule
myModule.defaultScatterPlot()
This won't work because myModule.py doesnot have access to AddPlot().
How do I do something like this ?
Thank you in advance for any help.
RDB
I am new to Python. I have the following question / problem.
I have a visualization software with command-line interface (CLI),
which essentially is a Python (v. 2.5) interpreter with functions
added to the global namespace. I would like to keep my own functions
in a separate module and then import that module to the main script
(that will be executed using the CLI interpreter). The problem is, I
cannot access the functions in the global namespace of the main script
from my module. Is there anyway to do that ?
Here is an example of what I meant. The function AddPlot() and
DrawPlots() are added to the global namespace by the software CLI. If
I do this:
mainscript.py:
---------------------------
AddPlot("scatter", "coordinate")
# set other things here
DrawPlots()
it works fine. But I want to be able to do this:
myModule.py:
----------------------
def defaultScatterPlot():
AddPlot("scatter", "coordinate")
#do other things
DrawPlots()
and then in mainscript.py:
---------------------------------------
import myModule
myModule.defaultScatterPlot()
This won't work because myModule.py doesnot have access to AddPlot().
How do I do something like this ?
Thank you in advance for any help.
RDB