Even better, make an 'UndoContext' context manager class (enter and exit methods), like:
def __exit__(self, *exc_info):
... your code here....
And then you can also pass in all sorts of things into the initializer of the class to correspond to undoInfo parameters. Wrap the shitty maya.cmds into something pythonic, one function at a time.