OILS / demo / cpython / readline_mod.py View on Github | oilshell.org

31 lines, 16 significant
1#!/usr/bin/env python2
2"""
3pyreadline.py
4
5TODO: Set up history/completion, and then strace. Where is the canonical example?
6
7NOTE: InteractiveLineReader does use raw_input(). Should it use something
8else?
9
10"""
11from __future__ import print_function
12
13import sys
14import readline
15
16
17def 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
26if __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)