i'm getting error. how fix this? missing using partials?
get_make_models(rows) = partial(groupby_attrs, attributes=['year', 'make'])
syntaxerror: can't assign function call
import itertools functools import partial def get_keyfunc(attributes): def keyfunc(row): """ returns row values attribues joined '-' """ values_arr = [row[attribute] attribute in attributes] return '-'.join(values_arr) return keyfunc def groupby_attrs(attributes, rows): keyfunc = get_keyfunc(attributes) data = sorted(rows, key=keyfunc) return itertools.groupby(data, key=keyfunc) get_year_make_models = partial(groupby_attrs, attributes=['year', 'make', 'model']) get_make_models(rows) = partial(groupby_attrs, attributes=['year', 'make'])
found it, looking @ right end of line. on left, can see variable function call. sorry mistake.
get_make_models(rows) = partial(groupby_attrs, attributes=['year', 'make'])
^^^^^^
Comments
Post a Comment