Here's the answer to this question. 

The summary of the question: how to run a module (called myapp.py) from 
another module (called myappwin.py) and be able to access the namespace of 
myapp.py from myappwin.py.

------------------------------------------
# contents of myapp.py
import math

class MyApp(object):
    def __init__(self):
        super(MyApp, self).__init__()
        self.name = "MyAppName"


def testFunction():
    boke = "Smilling"
    print math.sin(1), boke
-----------------------------------------
# contents of myappwin
def test():
    dic = {}
    execfile("myapp.py", dic)
    testObj = dic["MyApp"]() # access MyApp class
    dic["testFunction"]()    # execute testFunction
    print testObj.name       # print string


test()
-----------------------------------------
# OUTPUT
$ python myappwin.py
0.841470984808 Smilling
MyAppName

-- 

Kene
::::::::::::::::::
kemen...@gmail.com

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to