Copypasta is a straightforward way to implement for loops in text files. For example,
#{for i in range(5)} #{i + 1}, check! #{end}
becomes:
1, check! 2, check! 3, check! 4, check! 5, check!
The leading blank line results from the newline after the for block.
Call with:
$ ./copypasta.py test-range.txt.cp
You can start a for loop with for [key] in [values]
where values should be something which is iterable in Python, such as a list or a range. Every for
statement must be matched with an end
statement.