From: "Ka-Ping Yee" <python-dev@zesty.ca> > The attribute > protocols on Python built-in objects vary from type to type, and > pydoc tries to accommodate them. Part of the purpose of pydoc and > inspect was to document and provide a more uniform interface to some > of these protocols. > > All the built-in objects that are declared with a name have a __name__ > attribute, so you'll want to provide that. Beyond that, it depends > on the type of object you want to emulate; the various protocols are > documented in the 'inspect' module. For example, see > > pydoc inspect.isfunction Do you mean help(inspect.isfunction), or am I clueless about the environment which accepts the above command? > for details on function objects. It appears that ismethod is the one that's relevant to me, since the doc system gets my functions through my descriptor, which is wrapping them with PyMethod_New. So far I'm getting away with not adding an im_class attribute to my function objects, but it does result in that odd "__init__ = __init__" output (unless I've misdiagnosed). My function objects will certainly never have func_code, as help(inspect.isfunction) implies they should, and I'm a little reluctant to load up functions with a lot more attributes just so they can be like Python's functions... though I'm certain the penalty would be lost in the noise. The main question is this: which attributes do I absolutely /need/ in order to avoid raising an exception or giving nonsensical output from help()? Thanks again, Dave
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