According to this: http://docs.python.org/py3k/whatsnew/3.0.html they renamed __builtin__ to builtins (with removed underscores). So probably a bunch of ifs would do
On Sat, Dec 4, 2010 at 7:42 AM, Dan Stromberg <[email protected]> wrote: > This sounds promising, though sadly, it doesn't appear to work in Python 3.x: > > $ /usr/local/cpython-3.1/bin/python3 -c 'import __builtin__' > Traceback (most recent call last): > File "<string>", line 1, in <module> > ImportError: No module named __builtin__ > benchbox-dstromberg:~/src/home-svn/backshift/trunk i686-pc-linux-gnu > 22275 - above cmd done 2010 Fri Dec 03 09:40 PM > > $ /usr/local/cpython-3.0/bin/python3.0 -c 'import __builtin__' > Traceback (most recent call last): > File "<string>", line 1, in <module> > ImportError: No module named __builtin__ > benchbox-dstromberg:~/src/home-svn/backshift/trunk i686-pc-linux-gnu > 22275 - above cmd done 2010 Fri Dec 03 09:40 PM > > $ /usr/local/cpython-2.7/bin/python -c 'import __builtin__' > benchbox-dstromberg:~/src/home-svn/backshift/trunk i686-pc-linux-gnu > 22275 - above cmd done 2010 Fri Dec 03 09:41 PM > > $ /usr/local/cpython-2.6/bin/python -c 'import __builtin__' > benchbox-dstromberg:~/src/home-svn/backshift/trunk i686-pc-linux-gnu > 22275 - above cmd done 2010 Fri Dec 03 09:41 PM > > $ /usr/local/cpython-2.5/bin/python -c 'import __builtin__' > benchbox-dstromberg:~/src/home-svn/backshift/trunk i686-pc-linux-gnu > 22275 - above cmd done 2010 Fri Dec 03 09:41 PM > > $ > > > On Fri, Dec 3, 2010 at 11:37 AM, Maciej Fijalkowski <[email protected]> wrote: >> Use: >> >> import __builtin__ >> >> and treat it as module. __builtins__ is an ugly hack that is sometimes >> a dict and sometimes a module and pypy has different corner cases. >> __builtin__ will always work >> >> On Fri, Dec 3, 2010 at 9:13 PM, Leonardo Santagada <[email protected]> >> wrote: >>> (I'm guessing but) In python 2.5 modules are not iterable, you can use >>> getattr for the same effect. >>> >>> On Fri, Dec 3, 2010 at 5:04 PM, Dan Stromberg <[email protected]> wrote: >>>> How does one test if a function exists in pypy? >>>> >>>> In CPython 2.x and 3.x, it appears to be sufficient to use: >>>> >>>> 'funcname' in __bultins__ >>>> >>>> ...but that doesn't appear to work in pypy 1.4: >>>> >>>>>>>> print 'platform_version' in platform >>>> Traceback (most recent call last): >>>> File "<console>", line 1, in <module> >>>> TypeError: 'module' object is not iterable >>>>>>>> print 'bytes' in __builtins__ >>>> Traceback (most recent call last): >>>> File "<console>", line 1, in <module> >>>> TypeError: 'module' object is not iterable >>>>>>>> >>> >>> >>> >>> -- >>> Leonardo Santagada >>> _______________________________________________ >>> [email protected] >>> http://codespeak.net/mailman/listinfo/pypy-dev >> > _______________________________________________ [email protected] http://codespeak.net/mailman/listinfo/pypy-dev
