The reason seems to be that pylatex appends stuff to the commands argument without making a copy first, thus modifying the external list as can be seen here:
import pylatex
data = ["Hello world."]
for i in range(10):
print(commands[-1])
pylatex.Document(data=data).generate_tex()
A workaround is to call Document(..., data=["Hello world!"]) or Document(..., data=tuple(data)) or Document(..., data=data.copy()), but that should not be necessary.
I was wondering why this code
was generating this:
The reason seems to be that
pylatex
appends stuff to thecommands
argument without making a copy first, thus modifying the external list as can be seen here:A workaround is to call
Document(..., data=["Hello world!"])
orDocument(..., data=tuple(data))
orDocument(..., data=data.copy())
, but that should not be necessary.