Accessing global namespace from module

reubendb reubendb at
Mon Jun 11 18:02:48 CEST 2007

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:
AddPlot("scatter", "coordinate")
# set other things here

it works fine. But I want to be able to do this:
def defaultScatterPlot():
  AddPlot("scatter", "coordinate")
  #do other things

and then in
import myModule

This won't work because doesnot have access to AddPlot().
How do I do something like this ?

Thank you in advance for any help.

More information about the Python-list mailing list