[pypy-dev] Testing if a function exists?

Dan Stromberg drsalists at gmail.com
Fri Dec 3 20:04:23 CET 2010


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
>>>>

TIA!



More information about the Pypy-dev mailing list