What I found so far and use to navigate between classes in python-mode:
First C-M-u which runs the command python-nav-backward-up-list to navigate up to class definition. After that C-M-a (beginning-of-defun) and C-M-e (end-of-defun) to navigate to previous and next class definition respectively.
Use C-u C-c C-c.
See python-shell-buffer-substring function docstring:
When optional argument NOMAIN is non-nil everything under an if __name__ == '__main__' block will be removed.
When optional argument SEND-MAIN is non-nil, allow execution of
code inside blocks delimited by if __name__== '__main__':.
When called ...
Try usimng ipython blocks instead of python (#+BEGIN_SRC ipython) and add the following line to your first source block:
Note - I'm not sure if this will work with Spacemacs, but it is what scimax is all about. I used Spacemacs for about 6 months for python and jupyter notebooks before I switched to scimax for org-mode and never looked ...
You could use M-x compile with an appropriate compile-command value. e.g. as a file-local variable:
# -*- compile-command: "python file.py"; -*-
Emacs will prompt you to save (or not) the file before running the command.
Use M-! (M-x shell-command) if you want to run a shell command,
e.g. python file.py and print the output in a new buffer (*Shell
Command Output*). That does not open a shell in a new buffer.
Use M-x shell to run a shell in a new buffer as pointed by @NickD.