openmath/convert_pickle.py
def load_python_global(module, name):
    """
    Evaluate an OpenMath symbol describing a global Python object

    EXAMPLES::

        >>> from openmath.convert_pickle import to_python
        >>> from openmath.convert_pickle  import load_python_global
        >>> load_python_global('math', 'sin')
        <built-in function sin>

        >>> from openmath import openmath as om
        >>> o = om.OMSymbol(cdbase="http://python.org/", cd='math', name='sin')
        >>> to_python(o)
        <built-in function sin>
    """

    # The builtin module has been renamed in python3
    if module == '__builtin__' and six.PY3:
        module = 'builtins'
    module = importlib.import_module(module)
    return getattr(module, name)
def load_python_global(module, name):
    """
    Evaluate an OpenMath symbol describing a global Python object

    EXAMPLES::

        >>> from openmath.convert_pickle import to_python
        >>> from openmath.convert_pickle  import load_python_global
        >>> load_python_global('math', 'sin')
        <built-in function sin>

        >>> from openmath import openmath as om
        >>> o = om.OMSymbol(cdbase="http://python.org/", cd='math', name='sin')
        >>> to_python(o)
        <built-in function sin>
    """

    # The builtin module has been renamed in python3
    if module == '__builtin__' and six.PY3:
        module = 'builtins'
    module = importlib.import_module(module)
    return getattr(module, name)
Evaluate an OpenMath symbol describing a global Python object

    EXAMPLES::

        >>> from openmath.convert_pickle import to_python
        >>> from openmath.convert_pickle  import load_python_global
        >>> load_python_global('math', 'sin')
        <built-in function sin>

        >>> from openmath import openmath as om
        >>> o = om.OMSymbol(cdbase="http://python.org/", cd='math', name='sin')
        >>> to_python(o)
        <built-in function sin>