def unknown_column_message(table, column, haystack=None): if haystack is None: haystack = map(lambda c: c.name, table.columns()) logger.debug('haystack: %s', haystack) matches = get_close_matches(column, haystack) if not matches: return COLUMN_NOT_FOUND.format( column, table.name if table else '?', NO_CLOSE_MATCHES.format(u', '.join(haystack))) return COLUMN_NOT_FOUND.format( column, table.name if table else '?', CLOSE_MATCHES.format(u', '.join(matches)))