An example of an antipattern might be to use the with
inside a loop when it would be more efficient to have the with
outside the loop
for example
for row in lines:
with open("outfile","a") as f:
f.write(row)
vs
with open("outfile","a") as f:
for row in lines:
f.write(row)
The first way is opening and closing the file for each row
which may cause performance problems compared to the second way with opens and closes the file just once.