from collections import defaultdict


def group_seqlets(seqlets, by='seqname'):
    """Group seqlets by a certain feature
    """
    groups = defaultdict(list)
    for seqlet in seqlets:
        groups[getattr(seqlet, by)].append(seqlet)
    return groups