Package parser_course :: Package small_parsers :: Module var_printer
[hide private]
[frames] | no frames]

Source Code for Module parser_course.small_parsers.var_printer

1 -def debug_print (intro_string, Vars, Env, indent=3):
2 """ 3 Utility function for printing var values conveniently:: 4 -- C{intro_string}: arbitrary label of type string. Will 5 be printed as prefix to the info below. Usually the name 6 of the function calling C{debug_print}, but can be the 7 empty string. 8 __ C{Vars}: A tuple of varnames, that is, a tuple of expressions 9 that evaluate to var names. 10 -- C{Env}: A dictionary of variable name value pairs, usually 11 by calling C{vars()}. 12 For example:: 13 14 >>> var_printer.debug_print('scanner', ('goal_cat','index'),vars()) 15 16 prints:: 17 18 scanner 19 goal_cat: np 20 index : 0 21 22 if the values of the variables C{goal_cat} and C{index} in 23 environment C{vars()} are 'np' and '0' respectively. Note 24 the default indent of 3. 25 """ 26 27 print '%s: ' % intro_string 28 print_vars(Env, Vars, indent)
29 61