TableOfContents

Include(ZPyUGnav)

线程安全的模块导入

另外导入一个模块不必这么复杂, 这么写就可以了:

   1 import sys, os.path
   2 def my_import(fullpath):
   3    try:
   4        code = open(fullpath).read()
   5    except IOError:
   6        raise ImportError(fullpath)
   7 
   8    filename = os.path.basename(fullpath)
   9    m = type(sys)(filename)
  10    m.__file__ = fullpath
  11    exec compile(code, filename, 'exec') in m.__dict__
  12    return m

这样就不用担心线程问题, 在 Karrigell 中也可以用。


反馈

创建 by -- ZoomQuiet [DateTime(2008-12-16T05:39:28Z)]

PageComment2

[:/PageCommentData:PageCommentData]