From 3afb393e16accf0fb2277b8b1b2a5a564ab470da Mon Sep 17 00:00:00 2001 From: Fbenas Date: Sun, 8 Nov 2020 12:03:12 +0000 Subject: Upgrade print statements to python v3 syntax --- wikiquery | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/wikiquery b/wikiquery index 565752a..f0dcc3a 100755 --- a/wikiquery +++ b/wikiquery @@ -20,7 +20,7 @@ def stringify(o): return o.encode("utf-8", "replace") def display(o): - print stringify(o) + print (stringify(o)) def search(topic, index): results = wikipedia.search(topic) @@ -31,7 +31,7 @@ def search(topic, index): try: display(wikipedia.summary(results[index])) except IndexError: - print "index out of range, options are: [%s]" % stringify(results) + print ("index out of range, options are: [%s]" % stringify(results)) else: display(results) @@ -43,7 +43,7 @@ def url(topic, index): try: display(wikipedia.page(e.options[index]).url) except IndexError: - print "index out of range, options are: [%s]" % stringify(e.options) + print ("index out of range, options are: [%s]" % stringify(e.options)) else: display(e.options) else: @@ -57,12 +57,12 @@ def summary(topic, index): try: display(wikipedia.summary(e.options[index])) except IndexError: - print "index out of range, options are: [%s]" % stringify(e.options) + print ("index out of range, options are: [%s]" % stringify(e.options)) else: display(e.options) except wikipedia.exceptions.PageError as e: - print "No wikipedia results found for %s" %topic - + print ("No wikipedia results found for %s" %topic) + def parse_args(): args = sys.argv[1:] @@ -81,20 +81,20 @@ def main(): options, args = parse_args() if options.version: - print version + print (version) sys.exit(0) - + if args: topic = args.pop(0) while len(args) > 0 and not(isinstance(args[0], (int,long))): topic += " " + args.pop(0) - + index = int(args.pop(0)) if args else None if options.search: search(topic, index) elif options.url: - url(topic, index) + url(topic, index) else: summary(topic, index) -- cgit v1.2.3