diff options
author | Chiu Yue Chun <chiubrian@cuhk.edu.hk> | 2014-08-08 15:54:20 +0800 |
---|---|---|
committer | Chiu Yue Chun <chiubrian@cuhk.edu.hk> | 2014-08-08 15:54:20 +0800 |
commit | 96d2b49c8b46a6da85e58da8fbd6f7e6fd192eb7 (patch) | |
tree | b21ba4f87570b8f3dc7664d691019ab65c62a85f /pexpect/__init__.py | |
parent | 3c9644f1cd6af755517e730b8e712e3026b4628c (diff) | |
download | pexpect-git-96d2b49c8b46a6da85e58da8fbd6f7e6fd192eb7.tar.gz |
update documentation string in pexpect/__init__.py to be compatible with python 2 and 3
Diffstat (limited to 'pexpect/__init__.py')
-rw-r--r-- | pexpect/__init__.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/pexpect/__init__.py b/pexpect/__init__.py index cace43b..4a34f15 100644 --- a/pexpect/__init__.py +++ b/pexpect/__init__.py @@ -365,14 +365,19 @@ class spawn(object): Example log input and output to a file:: child = pexpect.spawn('some_command') - fout = file('mylog.txt','w') + fout = open('mylog.txt','wb') child.logfile = fout Example log to stdout:: + # In Python 2: child = pexpect.spawn('some_command') child.logfile = sys.stdout + # In Python 3, spawnu should be used to give str to stdout: + child = pexpect.spawnu('some_command') + child.logfile = sys.stdout + The logfile_read and logfile_send members can be used to separately log the input from the child and output sent to the child. Sometimes you don't want to see everything you write to the child. You only want to @@ -380,10 +385,13 @@ class spawn(object): child = pexpect.spawn('some_command') child.logfile_read = sys.stdout + + Remember to use spawnu instead of spawn for the above code if you are + using Python 3. To separately log output sent to the child use logfile_send:: - self.logfile_send = fout + child.logfile_send = fout If ``ignore_sighup`` is True, the child process will ignore SIGHUP signals. For now, the default is True, to preserve the behaviour of |