私は3つのPythonファイルを持っています
one.py、、two.py_three.py
one.py
one.py私が電話 するから
import two as two
two.three()
two.py私は持っています
def two():
"catch the error here then import and call three()"
import three as three
three.py私は持っています
def three():
print "three called"
だから当然私は得ています:
AttributeError:'function'オブジェクトに属性'three'がありません
私の質問は:
two.pyエラーをキャプチャしてからインポートthree.pyしてから呼び出す方法はありますthree()か?
__ _ __ _ __ _ _____編集____ __ _ __ _ __ _ __ _V私はそれを次のように呼ぶことができます
:
two().three()
def two():
import three as three
return three
しかし、私はそれをそのように呼びたいです:
two.three()
したがって、基本的にはdef two()を自動実行します。