'like enumerate, but with an upper limit on the number of items'

def _enumerate(self, seq):

    for (idx, x) in enumerate(seq):
        if (self.max_seq_length and (idx >= self.max_seq_length)):
            self.text(',')
            self.breakable()
            self.text('...')
            return
        (yield (idx, x))
