python - Expanding tuples in list comprehension generator -
i using function
def convert_tuple(self, listobj, fields=['start', 'end', 'user']): return [(getattr(obj, field) field in fields) obj in listobj] my desired output want should be
[('2am', '5am', 'john'), ('3am', '5am', 'john1'), ('3am', '5am', 'john2') ] the output of above function is
[genexp, genexp, genexp] its generator expression , not able expand wanted
typecast gen-exp tuple
def convert_tuple(self, listobj, fields=['start', 'end', 'user']): return [tuple(getattr(obj, field) field in fields) obj in listobj]
Comments
Post a Comment