Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
モジュールとしてexecfile(XX.py)ではなくスクリプトを実行するのは悪い習慣ですか? import XX私が興味を持っている理由は、ファイルを実行すると関数が に直接配置され__main__、明示的に渡す必要なくグローバルが使用できるようになるためです。しかし、これが問題を引き起こすかどうかはわかりません...ありがとう!
execfile(XX.py)
import XX
__main__
はい、それは悪い習慣です。すべてが__main__. 同じ名前の変数を持つ 2 つのモジュールがある場合、一方が他方を上書きします。