June 2000
Intermediate to advanced
556 pages
8h 45m
English
Every Python module has a variable called __doc__ associated with it. This variable holds any embedded documentation created by the programmer for the module. You can create documentation for a module by entering a string at the very top of the module file.
Moreover, if the first thing you type into a class/method/function or module is a string, it will become the documentation string associated with that class/method/function or module. Here is a SimpleInterest calculator with embedded documentation.
CD-ROM reference=6012.txt
>>> def SimpleInterest(p,t,r):
... "Simple Interest Rate Calculator"
... return (p * t * r)/100
We can interrogate the SimpleInterest function with our trusty dir command.
CD-ROM reference=6013.txt ...
Read now
Unlock full access