import os #Parameters: max_w = 80 cwd = os.getcwd() all_file_names = filter( lambda x: not os.path.isdir(x), os.listdir(cwd) ) file_names = filter( lambda x: x.endswith(".h") or x.endswith(".cpp"), all_file_names ) found_long_line = False for file_name in file_names: file = open(file_name,'r') lines = file.readlines() line_num = 0 for line in lines: line_num = line_num + 1 if( len(line) > max_w ): if not found_long_line: found_long_line = True print "Lines wider than " + str(max_w) + " characters found:" print file_name + ": line " + str(line_num)