def _get_python_block_output(src, global_dict, local_dict):
    """Evaluate python source codes

    Returns
    (bool, str):
      - True if success
      - output
    """
    src = '\n'.join([l for l in src.split('\n')
                     if not l.startswith('%') and not 'plt.show()' in l])
    ret_status = True
    err = ''
    with _string_io() as s:
        try:
            exec(src, global_dict, global_dict)
        except Exception as e:
            err = str(e)
            ret_status = False
    return (ret_status, s.getvalue()+err)
def _get_python_block_output ( src , global_dict , local_dict ) : src = '\n' . join ( [ l for l in src . split ( '\n' ) if not l . startswith ( '%' ) and not 'plt.show()' in l ] ) ret_status = True err = '' with _string_io ( ) as s : try : exec ( src , global_dict , global_dict ) except Exception as e : err = str ( e ) ret_status = False return ( ret_status , s . getvalue ( ) + err )
Evaluate python source codes

    Returns
    (bool, str):
      - True if success
      - output