def sample(collection, limit=3): """ Given an ordered collection (list, tuple, ...), return a string representation of the first limit items (or fewer), e.g. "itemA, itemB, itemC and 7 more" rsample does the sample, but shuffles the first 50 items and picks from that. """ return list_sample(collection, limit)
def rsample(collection, limit=3): """ Like sample, but uses a random subset of the first 50 items. """ return list_sample(sorted(collection[:50], key=lambda x: random()), limit)