Idiomatic way of repeating items in a sequence.

John Hunter jdhunter at ace.bsd.uchicago.edu
Mon Jun 30 17:58:15 CEST 2003


>>>>> "alr" == alr  <anlri at wmdata.com> writes:

    alr> reduce(lambda l, i: l + i, [[item] * repetitions for item in

This doesn't look too bad to me, but perhaps list comprehensions are
clearer?

  seq = ['a', 'b', 'c']
  print [x for x in seq for x in seq]







More information about the Python-list mailing list