Forum Discussion
I started to look at this but realised this is really a Python question not an F5 question so might have better luck asking on Stackoverflow.com. What you need is to send EOF, which is what Ctrl-D does, this might be just sending \0 (null) or \n\n at the end of your config string but never tried it.
Having said that think might be a better way. iControlREST is one option and the one I like the most, check out the example and look at the iControlREST info her on DevCentral. Python VS and Pool Create iControl example
The second is to upload you configure file to merge using SCP or SFTP then run the TMSH load merge command referencing the uploaded file but comes with its own challenges and risks, again not something I have tryed with python.