What do these builtins ought to be doing? Sent from Mail for Windows 10
From: Chris Smith Sent: 09 May 2019 03:08 To: sympy Subject: Re: [sympy] is compatibility builtins broken? None of them work >>> 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 >>> sys.modules['builtins']=__builtin__ Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name '__builtin__' is not defined but >>> from __builtin__ import type >>> 'builtins' in dir() True >>> builtins <module '__builtin__' (built-in)> >>> from builtins import type Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named builtins On Wednesday, May 8, 2019 at 7:34:27 AM UTC-5, Oscar wrote: 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/ac4c8667-a1ed-4e96-81e9-5933ffa8685f%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 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/5cd34d5c.1c69fb81.a4e7c.0d69%40mx.google.com. For more options, visit https://groups.google.com/d/optout.