示例#1
0
def as_tuples_iter(vqs, cols):
    """[{a=1, b=2}, {a=3, b=4}], ('a', 'b') -> (a=1, b=2), (a=3, b=4), ..."""
    Row = namedtuple('Row', cols)
    for row in vqs:
        yield Row(*[row[key] for key in cols])
示例#2
0
def as_tuples_iter(vqs, cols):
    """ Useful after queryset.values() """
    Row = namedtuple('Row', cols)
    for row in vqs:
        yield Row(*[row[key] for key in cols])
示例#3
0
def as_tuples(vqs, cols):
    """[{a=1, b=2}, {a=3, b=4}], ('a', 'b') -> [(a=1, b=2), (a=3, b=4)]"""
    Row = namedtuple('Row', cols)
    return [Row(*[row[key] for key in cols]) for row in vqs]
示例#4
0
def as_tuples(vqs, cols):
    """ Useful after queryset.values() """
    Row = namedtuple('Row', cols)
    return [Row(*[row[key] for key in cols]) for row in vqs]