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 | try:
|
19 | prompt_str = argv[1]
|
20 | except IndexError:
|
21 | prompt_str = '! '
|
22 | import os
|
23 | readline.parse_and_bind("tab: complete")
|
24 | print('PID %d' % os.getpid())
|
25 | while True:
|
26 | x = raw_input(prompt_str)
|
27 | print(x)
|
28 |
|
29 |
|
30 | if __name__ == '__main__':
|
31 | try:
|
32 | main(sys.argv)
|
33 | except RuntimeError as e:
|
34 | print('FATAL: %s' % e, file=sys.stderr)
|
35 | sys.exit(1)
|