def fix_embed_globals():
    """
    HACK adds current locals() to globals().
    Can be dangerous.
    """
    frame = get_stack_frame(N=1)
    frame.f_globals.update(frame.f_locals)
    frame.f_globals['_did_embed_fix'] = True
    """
    def fix_embed_globals(N=0):
        import inspect
        # Get the parent frame
        frame_cur = inspect.currentframe()
        for _ix in range(N + 1):
            # always skip the frame of this function
            frame_next = frame_cur.f_back
            if frame_next is None:
                break
            frame_cur = frame_next
        # Add locals to parent globals
        frame = frame_cur
        frame.f_globals.update(frame.f_locals)
        frame.f_globals['_did_embed_fix'] = True
    """
def fix_embed_globals ( ) : frame = get_stack_frame ( N = 1 ) frame . f_globals . update ( frame . f_locals ) frame . f_globals [ '_did_embed_fix' ] = True
HACK adds current locals() to globals().
    Can be dangerous.