Everything is possible, but this is the easiest, most reliable and readable way. Most shells supports this notation and autotest itself depends on similar constructs.

You can do it using subprocess by interactively sending new commands to bash. But that is less reliable and after a year unmaintainable (as everybody forgets what it's suppose to do). Other methods using python requires opening new process, which takes ages. Every QA knows bash enough to understand the for loop.