At 02:40 PM 5/10/2007 +1200, Greg Ewing wrote: >Phillip J. Eby wrote: > > For > > example, objects to be documented with pydoc currently have to > > reverse engineer a bunch of inspection code, while in a GF-based > > design they'd just add methods. > >There's a problem with this that I haven't seen a good >answer to yet. To add a method to a generic function, >you have to import the module that defines the base >function. So any module that wants its objects documented >in a custom way ends up depending on pydoc.
Using the "Importing" package from the Cheeseshop: def register_pydoc(pydoc): @when(pydoc.get_signature) def signature_for_mytype(ob:MyType) # etc. @when(pydoc.get_contents) def contents_for_mytype(ob:MyType) # etc. from peak.util.imports import whenImported whenImported('pydoc', register_pydoc) I certainly wouldn't object to making 'whenImported' and its friends a part of the stdlib. >There's also the possibility that other documentation >systems could make use of the same protocol if it's >designed appropriately, whereas extending pydoc-defined >generic functions benefits pydoc and nothing else. Of course; it's actually somewhat more likely that the basic GFs should actually live in "inspect" (or something like it) rather than in "pydoc" per se. _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com