Hmm - yes, that works for me, too. But in Py3 you can do 'from builtins 
import type' -- is the only way to do that in 2 is to use monkey patching?

/c

On Thursday, May 9, 2019 at 2:36:21 PM UTC-5, Aaron Meurer wrote:
>
> This works for me: 
>
> Python 2.7.14 | packaged by conda-forge | (default, Dec  9 2017, 16:31:12) 
> [GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin 
> Type "help", "copyright", "credits" or "license" for more information. 
> >>> from sympy.core.compatibility import builtins 
> >>> builtins.type 
> <type 'type'> 
>
> Aaron Meurer 
>
> On Thu, May 9, 2019 at 2:02 AM Chris Smith <[email protected] <javascript:>> 
> wrote: 
> > 
> > builtins is in core.compatibility and it doesn't seem to work for me. 
> > 
> > The issue will go away when we drop Py 2.7...or sooner if someone can 
> figure out what's wrong. 
> > 
> > On Wednesday, May 8, 2019 at 5:02:05 PM UTC-5, Aaron Meurer wrote: 
> >> 
> >> On Wed, May 8, 2019 at 3:48 PM Oscar Benjamin 
> >> <[email protected]> wrote: 
> >> > 
> >> > On Wed, 8 May 2019 at 22:38, Chris Smith <[email protected]> wrote: 
> >> > > 
> >> > > None of them work 
> >> > 
> >> > That's what I get for not trying them out! 
> >> > 
> >> > > >>> import sympy.core.compatibility.builtins as builtins 
> >> > > Traceback (most recent call last): 
> >> > >   File "<stdin>", line 1, in <module> 
> >> > > ImportError: No module named builtins 
> >> > > 
> >> > > >>> from sympy.core.compatibility.builtins import type 
> >> > > Traceback (most recent call last): 
> >> > >   File "<stdin>", line 1, in <module> 
> >> > > ImportError: No module named builtins 
> >> > 
> >> > Yes that's because there is no builtins module in the compatibility 
> >> > package. In fact compatibility is a module not a package. 
> >> > 
> >> > > >>> sys.modules['builtins']=__builtin__ 
> >> > > Traceback (most recent call last): 
> >> > >   File "<stdin>", line 1, in <module> 
> >> > > NameError: name '__builtin__' is not defined 
> >> > 
> >> > This will work if you have imported __builtin__ first: 
> >> > 
> >> > >>> import __builtin__ 
> >> > >>> import sys 
> >> > >>> sys.modules['builtins'] = __builtin__ 
> >> > >>> import builtins 
> >> 
> >> What is this for? We shouldn't be monkey-patching sys.modules in 
> library code. 
> >> 
> >> Aaron Meurer 
> >> 
> >> > 
> >> > -- 
> >> > 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 [email protected]. 
> >> > To post to this group, send email to [email protected]. 
> >> > 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/CAHVvXxQ59yzRzns5MHiqNmZz09Tx82B4aF_CnvidTwMGPA9E6Q%40mail.gmail.com.
>  
>
> >> > For more options, visit https://groups.google.com/d/optout. 
> > 
> > -- 
> > 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 [email protected] <javascript:>. 
> > To post to this group, send email to [email protected] 
> <javascript:>. 
> > 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/bb44f6d2-8d32-410b-97e7-5bd4e2409a2a%40googlegroups.com.
>  
>
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
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/13957bcc-ec40-4f21-a2c0-05576db5db53%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to