import subprocess import time tbl =[["on",2],["dn",2],["dn",2],["dn",2],["dn",2], ["up",2],["up",2],["up",2],["up",2], ["off",4],["sml",2]] while True: for i in range(len(tbl)) : subprocess.call(["cgir", "send", "light:"+tbl[i][0], "-g", "13"]) time.sleep(tbl[i][1])