Running external module and accessing the created objects

Kene Meniru Kene.Meniru at
Tue Mar 12 00:57:28 CET 2013

Here's the answer to this question. 

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

# contents of
import math

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

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

$ python
0.841470984808 Smilling


KeMeniru at

More information about the Python-list mailing list