##// END OF EJS Templates
Override input(), not raw_input(), for Qt console in Python 3.
Thomas Kluyver -
Show More
@@ -33,6 +33,7 b' from IPython.core.shellapp import ('
33 InteractiveShellApp, shell_flags, shell_aliases
33 InteractiveShellApp, shell_flags, shell_aliases
34 )
34 )
35 from IPython.utils import io
35 from IPython.utils import io
36 from IPython.utils import py3compat
36 from IPython.utils.jsonutil import json_clean
37 from IPython.utils.jsonutil import json_clean
37 from IPython.lib import pylabtools
38 from IPython.lib import pylabtools
38 from IPython.utils.traitlets import (
39 from IPython.utils.traitlets import (
@@ -219,6 +220,9 b' class Kernel(Configurable):'
219 # Replace raw_input. Note that is not sufficient to replace
220 # Replace raw_input. Note that is not sufficient to replace
220 # raw_input in the user namespace.
221 # raw_input in the user namespace.
221 raw_input = lambda prompt='': self._raw_input(prompt, ident, parent)
222 raw_input = lambda prompt='': self._raw_input(prompt, ident, parent)
223 if py3compat.PY3:
224 __builtin__.input = raw_input
225 else:
222 __builtin__.raw_input = raw_input
226 __builtin__.raw_input = raw_input
223
227
224 # Set the parent message of the display hook and out streams.
228 # Set the parent message of the display hook and out streams.
@@ -25,6 +25,7 b' import traceback'
25 import zmq
25 import zmq
26
26
27 # Local imports.
27 # Local imports.
28 from IPython.utils import py3compat
28 from IPython.utils.traitlets import HasTraits, Instance, Dict, Float
29 from IPython.utils.traitlets import HasTraits, Instance, Dict, Float
29 from completer import KernelCompleter
30 from completer import KernelCompleter
30 from entry_point import base_launch_kernel
31 from entry_point import base_launch_kernel
@@ -116,6 +117,9 b' class Kernel(HasTraits):'
116 # Replace raw_input. Note that is not sufficient to replace
117 # Replace raw_input. Note that is not sufficient to replace
117 # raw_input in the user namespace.
118 # raw_input in the user namespace.
118 raw_input = lambda prompt='': self._raw_input(prompt, ident, parent)
119 raw_input = lambda prompt='': self._raw_input(prompt, ident, parent)
120 if py3compat.PY3:
121 __builtin__.input = raw_input
122 else:
119 __builtin__.raw_input = raw_input
123 __builtin__.raw_input = raw_input
120
124
121 # Set the parent message of the display hook and out streams.
125 # Set the parent message of the display hook and out streams.
General Comments 0
You need to be logged in to leave comments. Login now