There are often times where expect-send is needed on normal files, instead of a process.
The file object passed to an unspawned objects are assumed to be owned by another part of the process. This means that closing these objects does not close the file.
import select, socket
remote = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
remote.connect('localhost', 'smtp')
spawn_id = ExpectPy.spawnfile(remote)
select.select([spawn_id], [], [])
spawn_id.expect((ExpectPy.GLOB, "200 *\r\n", 1))
spawn_id.send("HELO localhost\r")
...
spawn_id.send("QUIT\r")
spawn_id.close()
remote.close()