diff options
author | Steven Myint <git@stevenmyint.com> | 2013-10-08 19:46:16 -0700 |
---|---|---|
committer | Steven Myint <git@stevenmyint.com> | 2013-10-08 19:46:16 -0700 |
commit | a34cfbdde75d8d0aa276afeeb824522fe82a7b34 (patch) | |
tree | e1d41ea40131dcc927906b67cdcf4cbc6a156688 /examples/python.py | |
parent | 1141915a17bd446d330de0c8fe3a017ebc6b2e06 (diff) | |
download | pexpect-git-a34cfbdde75d8d0aa276afeeb824522fe82a7b34.tar.gz |
Add note about unicode_literals and spawnu
Diffstat (limited to 'examples/python.py')
-rwxr-xr-x | examples/python.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/examples/python.py b/examples/python.py index 9945762..d8ad7f4 100755 --- a/examples/python.py +++ b/examples/python.py @@ -30,7 +30,12 @@ from __future__ import unicode_literals # c = pexpect.spawn ('/usr/bin/env python ./python.py') import pexpect + +# Note that, for Python 3 compatibility reasons, we are using spawnu and +# importing unicode_literals (above). spawnu accepts Unicode input and +# unicode_literals makes all string literals in this script Unicode by default. c = pexpect.spawnu('/usr/bin/env python') + c.expect('>>>') print('And now for something completely different...') print(''.join(reversed((c.before)))) |