]> git.phdru.name Git - m_lib.git/blobdiff - m_lib/tty_menu.py
Use int() instead of atoi() for Py3 compatibility
[m_lib.git] / m_lib / tty_menu.py
index 897ecc9a8b2764ef02c1db51f4f03bbaef39152d..852de1d601929faf2e3a4ec6b9328f9011bd51cb 100755 (executable)
@@ -6,6 +6,12 @@ from __future__ import print_function
 import string
 
 
+try:
+   raw_input
+except NameError:  # Python 3
+   raw_input = input
+
+
 def hmenu(prompt, astring):
    """
       Writes prompt and read result
@@ -32,8 +38,8 @@ def vmenu(item_list, prompt, format = "%d. %s"):
    result = raw_input(prompt)
 
    try:
-      result = string.atoi(result)
-   except string.atoi_error:
+      result = int(result)
+   except ValueError:
       result = -1
 
    return result