From a05f7822b10ed4cdd61ed8384299a003baf1c1c6 Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Wed, 16 Apr 2014 22:42:17 -0500 Subject: Python: metadata on builtin funcs. Support python3. --- python/mal_readline.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'python/mal_readline.py') diff --git a/python/mal_readline.py b/python/mal_readline.py index e8cf957..2add6b5 100644 --- a/python/mal_readline.py +++ b/python/mal_readline.py @@ -1,7 +1,11 @@ -import os, readline as pyreadline +import os, sys, readline as pyreadline history_loaded = False histfile = os.path.expanduser("~/.mal-history") +if sys.version_info[0] >= 3: + rl = input +else: + rl = raw_input def readline(prompt="user> "): if not history_loaded: @@ -15,7 +19,7 @@ def readline(prompt="user> "): pass try: - line = raw_input(prompt) + line = rl(prompt) pyreadline.add_history(line) with open(histfile, "a") as hf: hf.write(line + "\n") -- cgit v1.2.3