From 1c416093518c7c358096802e911c00d29a810b18 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Sat, 20 Jun 2015 21:46:39 +0200 Subject: Make all examples Python 3-friendly. print -> print(). Skip 'from __future__ import print_function' by only having a single argument (to avoid interpretation as tuples in Python 2). Keeps the examples simple. --- examples/help_grep.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'examples/help_grep.py') diff --git a/examples/help_grep.py b/examples/help_grep.py index 93b086a..61ac936 100644 --- a/examples/help_grep.py +++ b/examples/help_grep.py @@ -8,13 +8,13 @@ import kconfiglib import sys if len(sys.argv) < 3: - print 'Pass search string with SCRIPT_ARG="search string"' + print('Pass search string with SCRIPT_ARG="search string"') sys.exit(1) search_string = sys.argv[2].lower() conf = kconfiglib.Config(sys.argv[1]) -for item in conf.get_symbols() +\ +for item in conf.get_symbols() + \ conf.get_choices() + conf.get_menus() + conf.get_comments(): if item.is_symbol() or item.is_choice(): text = item.get_help() @@ -34,19 +34,16 @@ for item in conf.get_symbols() +\ # keep things simple fname, linenr = item.get_def_locations()[0] if item.is_symbol(): - print "config {0} at {1}:{2}:\n{3}".\ - format(item.get_name(), fname, linenr, text) + print("config {0} at {1}:{2}:\n{3}" + .format(item.get_name(), fname, linenr, text)) elif item.is_choice(): - print "choice at {0}:{1}:\n{2}".\ - format(fname, linenr, text) + print("choice at {0}:{1}:\n{2}".format(fname, linenr, text)) else: # Menu or comment fname, linenr = item.get_location() if item.is_menu(): - print 'menu "{0}" at {1}:{2}'.\ - format(text, fname, linenr) + print('menu "{0}" at {1}:{2}'.format(text, fname, linenr)) else: # Comment - print 'comment "{0}" at {1}:{2}'.\ - format(text, fname, linenr) + print('comment "{0}" at {1}:{2}'.format(text, fname, linenr)) -- cgit v1.2.3