On Feb 16, 2005, at 11:02, Phillip J. Eby wrote: > At 02:32 PM 2/11/05 -0800, Nick Rasmussen wrote: >> tommy said that this would be the best place to ask >> this question.... >> >> I'm trying to get functions wrapped via boost to show >> up as builtin types so that pydoc includes them when >> documenting the module containing them. Right now >> boost python functions are created using a PyTypeObject >> such that when inspect.isbuiltin does: >> >> return isinstance(object, types.BuiltinFunctionType) > > FYI, this may not be the "right" way to do this, but since 2.3 > 'isinstance()' looks at an object's __class__ rather than its type(), > so you could perhaps include a '__class__' descriptor in your method > type that returns BuiltinFunctionType and see if that works. > > It's a kludge, but it might let your code work with existing versions > of Python. It works in Python 2.3.0: import types class FakeBuiltin(object): __doc__ = property(lambda self: self.doc) __name__ = property(lambda self: self.name) __self__ = property(lambda self: None) __class__ = property(lambda self: types.BuiltinFunctionType) def __init__(self, name, doc): self.name = name self.doc = doc >>> help(FakeBuiltin("name", "name(foo, bar, baz) -> rval")) Help on built-in function name: name(...) name(foo, bar, baz) -> rval -bob
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4