Execute a list of magic commands

For certain purposes it may be convenient to execute a list of magic commands. Here is an example:

 
#!/usr/bin/env python

import IPython

ip = IPython.get_ipython()

mg = "mg_ivp"

comList = [
    "change_mg -g %s -t d1_t01 -c d1_c01" % mg,
    "ascan exp_dmy01 0 1 10 0.1",
    "delete_mg %s" % mg,
]

for com in comList:
    ip.magic(com)