You can call execfile(filename). More or less the same as importing a module, except that it skips the module administration part and doesn't require you to add a folder to sys.path.
EDIT: To address the original question: copy-pasted code can be executed by calling exec(codestring).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…