Exemplo n.º 1
0
def fix_embed_globals():
    """
    HACK adds current locals() to globals().
    Can be dangerous.
    """
    import utool as ut
    globals_ = ut.get_parent_globals()
    locals_ = ut.get_parent_locals()
    globals_.update(locals_)
    globals_['wasfixed'] = True
Exemplo n.º 2
0
def evalprint(str_, globals_=None, locals_=None, simplify=False):
    if globals_ is None:
        globals_ = ut.get_parent_globals()
    if locals_ is None:
        locals_ = ut.get_parent_locals()
    if isinstance(str_, six.string_types):
        var = eval(str_, globals_, locals_)
    else:
        var = str_
        str_ = ut.get_varname_from_stack(var, N=1)
    if simplify is True:
        var = sympy.simplify(var)
    print(ut.hz_str(str_ + " = ", repr(var)))
Exemplo n.º 3
0
def evalprint(str_, globals_=None, locals_=None, simplify=False):
    if globals_ is None:
        globals_ = ut.get_parent_globals()
    if locals_ is None:
        locals_ = ut.get_parent_locals()
    if isinstance(str_, six.string_types):
        var = eval(str_, globals_, locals_)
    else:
        var = str_
        str_ = ut.get_varname_from_stack(var, N=1)
    if simplify is True:
        var = sympy.simplify(var)
    print(ut.hz_str(str_ + ' = ', repr(var)))