[C++-sig] Re: Boost.Python functions and Python functions

Daniel Holth dholth at fastmail.fm
Sun Feb 1 10:45:08 CET 2004


On Sat, 2004-01-31 at 21:29, David Abrahams wrote:
> If pydoc really only works on classes derived from Python's builtin
> function types, it probably *should* be changed.
> 
> > Is there a good reason that Boost doesn't currently subtype Python's
> > Function Type for its functions?
> 
> You mean aside from:
...
>   TypeError: type 'function' is not an acceptable base type
> 
> ??

This is the exact test pydoc (via inspect.py) uses to determine if
something is a function: "isinstance(object, types.FunctionType)".

This evaluates to true for PyCFunction and PyFunction, builtin functions
and normal Python functions, so perhaps Boost's functions can be made to
to pass this test.  pydoc could also be changed to document as a
function anything that had a __call__ property.

- dwh





More information about the Cplusplus-sig mailing list