summaryrefslogtreecommitdiff
path: root/pexpect/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'pexpect/__init__.py')
-rw-r--r--pexpect/__init__.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/pexpect/__init__.py b/pexpect/__init__.py
index b3a64b6..1c6bdb7 100644
--- a/pexpect/__init__.py
+++ b/pexpect/__init__.py
@@ -29,6 +29,12 @@ For example::
child.expect('Password:')
child.sendline(mypassword)
+Context manager can be used for the spawn() function::
+
+ with pexpect.spawn('scp foo user@example.com:.') as child:
+ child.expect('Password:')
+ child.sendline(mypassword)
+
This works even for commands that ask for passwords or other input outside of
the normal stdio streams. For example, ssh reads input directly from the TTY
device which bypasses stdin.