Loading functions from a file during run-time

Wensheng wenshengwang at gmail.com
Thu Feb 17 11:51:55 EST 2005


f=open("bar.txt")
import imp
fs=imp.new_module("fs")
exec f in fs.__dict__
.... rests are the same

althought why use anything other than .py, when you import .py, it get
compiled into .pyc and it load faster next time




More information about the Python-list mailing list