1 | #!/usr/bin/env python2
|
2 | """
|
3 | pyreadline.py
|
4 |
|
5 | TODO: Set up history/completion, and then strace. Where is the canonical example?
|
6 |
|
7 | NOTE: InteractiveLineReader does use raw_input(). Should it use something
|
8 | else?
|
9 |
|
10 | """
|
11 | from __future__ import print_function
|
12 |
|
13 | import sys
|
14 | import readline
|
15 |
|
16 |
|
17 | def main(argv):
|
18 | import os
|
19 | readline.parse_and_bind("tab: complete")
|
20 | print('PID %d' % os.getpid())
|
21 | while True:
|
22 | x = raw_input('! ')
|
23 | print(x)
|
24 |
|
25 |
|
26 | if __name__ == '__main__':
|
27 | try:
|
28 | main(sys.argv)
|
29 | except RuntimeError as e:
|
30 | print('FATAL: %s' % e, file=sys.stderr)
|
31 | sys.exit(1)
|