What's the standard way to turn a code object into a function ?

Wild Bill reallywildbill at hotmail.com
Thu Aug 2 15:36:39 EDT 2001


How would you fill in the missing lines?

    codeObj = compile(sBody, "", "exec")
    #
    # Turn 'codeObj' into function 'f' 
    ..
    # Later, use 'f'
    x = f(1, "blue", 3.1416)

Ideally, I'm looking for something elegant, i.e., that doesn't
call "exec" when performing f.

Thanks!

Bill



More information about the Python-list mailing list