プログラム全体を停止せずに、インポート中のモジュールの評価を停止したいのですが。
これが私が達成したいことの例です:
main.py
print('main1') import testmodule print('main2')
testmodule.py
print(' module1') some_condition=True if some_condition: exit_from_module() # How to do this? print(' module2') # This line is not executed.
期待される出力:
main1 module1 main2