Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if __name__ == '__main__':
- print('script_2 is the main!')
- import importlib.util
- spec = importlib.util.spec_from_file_location('__main__', 'script_2.py')
- mod = importlib.util.module_from_spec(spec)
- spec.loader.exec_module(mod)
- if __name__ == '__main__':
- print('script_3 is the main!')
- python script_1.py
- > script_2 is the main!
- > script_1 is the main!
Add Comment
Please, Sign In to add comment