On Wed, 7 Aug 2002, Guido van Rossum wrote: > > It seems I'm breaking some protocol. It's easy enough to add a '__name__' > > attribute to my function objects, but I'd like to be sure that I'm adding > > everything I really /should/ add. Just how much like a regular Python > > function does my function have to be in order to make the help system (and > > other standard systems with such expectations) happy? > > It's hard to say. The pydoc code makes up protocols as it goes. I > think __name__ is probably the only one you're missing in practice. pydoc does not "make up protocols as it goes". It does its best to utilize the protocols exposed by the Python core. 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 for details on function objects. -- ?!ng
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