You do not need to save the file, you can run the current buffer as stdin for a command such as python by typing:
:w !python -
(The hyphen at the end is probably not needed, python will usually use stdin by default)
edit: seeing that you are new to vim, note that this will not save the file, it will just run it. You will probably want to know how to save the file.
source share