On Wed, 8 May 2019 at 08:23, Chris Smith <smi...@gmail.com> wrote:
>
> Am I doing something wrong here when running Python 2?
>
> >>> from sympy.core.compatibility import builtins
> >>> from builtins import type
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> ImportError: No module named builtins

There are two possible wrong things:

1) On Python 2 the module is called __builtin__:

    >>> import __builtin__
    >>> __builtin__.map
    <built-in function map>

2) You've imported the name builtins so that it is available as a name
in the current global namespace. That does not mean that a subsequent
import statement will import from the resulting module object. An
import statement never looks at the names in the current namespace to
find anything. You can however do

    import sympy.core.compatbility.builtins as builtins
    builtins.type

Or

    from sympy.core.compatibility.builtins import type

Not sure what you're aiming for but there is a hacky way to do it:

    sys.modules['builtins'] = builtins

--
Oscar

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAHVvXxSP8sf1b03i-Wy6YnLonq8g6efkJzgaoTxtMeeF3d0UsA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to