[ create a new paste ] login | about

Link: http://codepad.org/wESS0m2e    [ raw code | output | fork ]

Python, pasted on Jun 27:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import imp

mod = None
func = None

code = """
a = 42

def func():
    print a
"""

def main():
    global mod
    global func
    mod = imp.new_module("modulename")
    exec code in mod.__dict__
    func = mod.func

main()
func()


Output:
1
42


Create a new paste based on this one


Comments: