Emacs has a built-in function that works with the python shell (bottom) to prevent inadvertent use of the entire script, which happens by overriding (or deleting) __name__before it runs.
script __name__ = "__main__", - " ".
, , main, :
`C-u C-c C-c`
, - , - :
(global-set-key (kbd "<f7>") (kbd "C-u C-c C-c"))
, .