已读37%
预计阅读本页时间:-
预计阅读本页时间:-
Test Your Knowledge: Answers
- Documentation strings (docstrings) are considered best for larger, functional documentation, describing the use of modules, functions, classes, and methods in your code. Hash-mark comments are today best limited to micro-documentation about arcane expressions or statements. This is partly because docstrings are easier to find in a source file, but also because they can be extracted and displayed by the PyDoc system.
- You can see docstrings by printing an object’s __doc__ attribute, by passing it to PyDoc’s help function, and by selecting modules in PyDoc’s GUI search engine in client/server mode. Additionally, PyDoc can be run to save a module’s documentation in an HTML file for later viewing or printing.
- The built-in dir(X) function returns a list of all the attributes attached to any object.
- Run the PyDoc GUI interface, leave the module name blank, and select “open browser”; this opens a web page containing a link to every module available to your programs.
- Mine, of course. (Seriously, the Preface lists a few recommended follow-up books, both for reference and for application tutorials.)