1

I have something like this:

from CoreTemplate import CoreTemplate

when i want to use the imported function from CoreTemplate Module I need to do like this:

CoreTemplate.ifunction()

are there anyway that i can call function without name of the module like this:

ifunction()
4

3 回答 3

0

应该这样做;

from CoreTemplate import CoreTemplate

g = globals()

for atr in dir(CoreTemplate):
    if atr.startswith("_"):
        continue
    g[atr] = getattr(CoreTemplate, atr)
于 2013-02-04T09:53:07.607 回答
0

你可以做

from CoreTemplate import CoreTemplate
ifunction = CoreTemplate.ifunction

(注意没有括号)

于 2013-02-04T09:03:00.160 回答
0
from CoreTemplate import ifunction

ifunction()
于 2013-02-04T09:07:37.287 回答