次はpythonのimport
import されたら main 以下は実行されない
def sub(x,y): return x - y if __name__ == "__main__": print sub(10000, 1)
test_module.py を import (基本)
import test_module a = test_module.Test() a.sayStr("Hello")
モジュールからクラスをimport(from登場)
from test_module import Test a = Test() a.sayStr("Hello")
クラスに別名(as登場)
from test_module import Test as Test2 a = Test2() a.sayStr("Hello")
モジュールに別名(as)
import test_module as test a = test.Test() a.sayStr("Hello")