'subprocess.Popen['vim'] in an interactive Python session yields interesting results

Enter python shell

then type

import subprocess
subprocess.Popen("vim")

Then the vim window opens. Try to quit vim using :q and then try typing in the interactive session.

It seems like vim does not really actually quit. It seems as if I was in vim and in the Python shell at the same time.

Why does this happen?

I know that I can avoid this by running subprocess.call or Popen.communicate() etc., I am just curious as to what exactly is happening.

It seems as if quitting vim using :q after running it in Popen still kind of keeps it running.

Image of the mess generated after Popening vim and quitting



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source