In this chapter, we say the document string: __doc__
A document string is actually a comment, but it is usually placed at the top of a module file, function, or class statement, mainly to explain what they are doing, and why.
Python automatically encapsulates the text and puts it in the __doc__ attribute
Next, let's talk about the built-in document string
Python's interior has provided a lot of documents to us, when we import the module, we only need to print the module's __doc__ property, we can probably know what the module is doing, there are methods list, etc.
>>> Import sys>>> Print (sys.__doc__) This module provides access to some objects used or maintained by th Einterpreter and to functions this interact strongly with the interpreter. Dynamic objects:argv-command line arguments; ARGV[0] is the script pathname if Knownpath-module search path; PATH[0] is the script directory, else "modules--Dictionary of Loaded Modulesdisplayhook--called to show results in an Interactive Sessionexcepthook--called to handle any uncaught exception other than systemexit to customize printing in An interactive session or to install a custom top-level exception handler, assign other functions to replace These.stdin --standard input file object; Used by input () stdout – standard output file object; Used by print () stderr – standard Error object; Used for error messages by assigning and other file objects (or objects so behave like files) to these, it's possible to Redirect all of the Interpreter's i/o.last_type--type of last UncaUght Exceptionlast_value--value of last uncaught exceptionlast_traceback--Traceback of last uncaught exception these Three is available in an interactive session after a traceback have been printed. Static Objects:builtin_module_names--tuple of module names built into this interpretercopyright--copyright notice PERT Aining to this interpreterexec_prefix--prefix used to find the machine-specific Python libraryexecutable--Absolute Pat H of the executable binary of the Python interpreterfloat_info--a struct sequence with information about the float imple Mentation.float_repr_style--string indicating the style of repr () output for floatshash_info--a struct sequence with I Nformation about the hash algorithm.hexversion--version information encoded as a single integerimplementation--Python Implementation Information.int_info--a struct sequence with information about the int implementation.maxsize--The Larg EST supported length of containers.maxunicode--the valueof the largest Unicode code Pointplatform--platform Identifierprefix--prefix used to find the Python Librarythread_inf O--a struct sequence with information on the thread implementation.version--The version of this interpreter as a St Ringversion_info--version information as a named Tupledllhandle--[Windows only] integer handle of the Python Dllwinver --[Windows only] version number of the Python dll__stdin__-the original stdin; Don ' t touch!__stdout__-the original stdout; Don ' t touch!__stderr__-the original stderr; Don ' t touch!__displayhook__-the original displayhook; Don ' t touch!__excepthook__-the original excepthook; Don ' t touch! Functions:displayhook ()--Print an object to the screens, and save it in Builtins._excepthook ()--Print an exception and Its traceback to Sys.stderrexc_info ()--return thread-safe information about the current exceptionexit ()--Exit the inte Rpreter by Raising Systemexitgetdlopenflags ()--Returns the flags to being used for Dlopen () cAllsgetprofile ()--Get the Global Profiling Functiongetrefcount ()--Return the reference count for an object (plus one: -) Getrecursionlimit ()--return the max recursion depth for the interpretergetsizeof ()--return the size of a object in Bytesgettrace ()--Get the Global Debug Tracing Functionsetcheckinterval ()--control how often the interpreter checks for Eventssetdlopenflags ()--set the flags to being used for Dlopen () Callssetprofile ()--Set the global profiling Functionset Recursionlimit ()--Set the max recursion depth for the interpretersettrace ()--Set the global debug tracing function> >>
In summary, our section describes how to use document strings and simply explains the use of built-in document strings
This chapter is here, thank you.
------------------------------------------------------------------
Click to jump 0 basic python-Catalogue
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
0 Fundamentals python-14.2 Python's documentation resources: Document strings