[python-uk] How to access a class instance created in one module in another module?
xtian at babbageclunk.com
Thu Apr 29 11:29:07 CEST 2010
On Wed, Apr 28, 2010 at 3:02 PM, Goodies <sachin_chavan at yahoo.com> wrote:
> I have a query. I have two modules viz. MnSem5Main.py and MnCEMMain.py in
> different folders.
> I have created the below instances in MnSem5Main.py:
> 'app' , 'frame'
> Please note that 'app' is created using wx.App and 'frame' using wx.Frame
> builtin classes.
> I want to access these in MnCEMMain.py. How to access these instances?
Your terminology is a little muddled here. It sounds like what you
mean is that you created classes called app and frame in MnSem5Main.py
which subclass (or inherit from) wx.App and wx.Frame.
if MnSem5Main.py is on your PYTHONPATH, you can import the classes by
putting the following line in MnSem5Main.py:
from MnSem5Main import app, frame
Then you can create instances of the classes by calling them with the
Even if app and frame are instances of classes instead of classes, the
import statement will get them from the MnSem5Main namespace and put
them in your namespace.
More information about the python-uk