def py2tex(codestr):
    """Convert a python code string to LaTex"""
    strout = codestr.replace("'", '^T')
    strout = strout.replace('*', '')
    strout = strout.replace('.^', '^')
    strout = '$' + strout + '$'
    return strout
