Replace raw_input/input with six.moves.input for python 2/3 (#18461)
In python 3 input is the equivalent of raw_input in python 2. This fix is an enhancement to replace raw_input/input with six.moves.input, which is compatible with both python 2 and python 3. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
parent
f185600509
commit
1ab692972f
@ -19,6 +19,8 @@ from __future__ import print_function
|
|||||||
|
|
||||||
import readline
|
import readline
|
||||||
|
|
||||||
|
import six
|
||||||
|
|
||||||
from tensorflow.python.debug.cli import base_ui
|
from tensorflow.python.debug.cli import base_ui
|
||||||
from tensorflow.python.debug.cli import debugger_cli_common
|
from tensorflow.python.debug.cli import debugger_cli_common
|
||||||
|
|
||||||
@ -39,11 +41,7 @@ class ReadlineUI(base_ui.BaseUI):
|
|||||||
readline.set_completer(self._readline_complete)
|
readline.set_completer(self._readline_complete)
|
||||||
readline.parse_and_bind("tab: complete")
|
readline.parse_and_bind("tab: complete")
|
||||||
|
|
||||||
# For Python 2-3 compatibility.
|
self._input = six.moves.input
|
||||||
try:
|
|
||||||
self._input = raw_input
|
|
||||||
except NameError:
|
|
||||||
self._input = input
|
|
||||||
|
|
||||||
def _readline_complete(self, text, state):
|
def _readline_complete(self, text, state):
|
||||||
context, prefix, except_last_word = self._analyze_tab_complete_input(text)
|
context, prefix, except_last_word = self._analyze_tab_complete_input(text)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user