Python quick way to generate comment documents
Today, we will tell you a simple little detail that you can easily make note of, and you can also check whether the class method reference name we wrote has a duplicate problem. A look at the other professional Daniel wrote more than the envy of the document, do not worry we can let python for us to generate a basic description of the document, one can improve the overall code reading, and the overall structure of the code can also be seen more clearly, so in the handover can save a lot of trouble, Other colleagues in the process of taking over your work will not be a line to ask you what that is what that is, because the comments have been very intuitive expression, in the integration when the description of the document to the customer simple description (mainly to your boss to see), then go to the topic how to realize see below my simple code format, Note that the local and function names of the annotations are associated with the __all__ within the
#!/usr/bin/env python#-*-coding:utf-8-*-"Document Quick Comment Method Introduction, first we want to use the __all__ property in the PY for export __all__ all classes, functions, variable members, etc. in the module use __ ALL__ Properties Avoid naming conflicts when referencing to each other "' __all__ = [' Login ', ' check ', ' Shop ', ' Updateit ', ' findIt ', ' DeleteIt ', ' Createit ']class Login: ' ' Test note One can write a description of the function of this class, such as this method is used to write login ' Def __init__ (self): ' ' Initialize the parameter description you want, then login may need to use the user Name username password Password "pass def check (self):" Negotiation you want to implement the function description function also has a lot of such as verification The "Passclass Shop:" The Product class contains properties and methods Update/update find find delete delete create add "' Def __init__ (self): ' Initialize the price, date, category, etc. of the product ' ' Pass def Updateit (self): ' Used to update product information ' ' Pass def findIt (self): ' Find product info ' ' Pass def DeleteIt ( Self): ' Delete expired shelf product Information ' Pass Def Createit (self): ' Create new product and listing information ' Passif __name__== "__main__": Import Pythonzhushi Print help (Pythonzhushi)
It is emphasized here that the name of the PY is the same as the PY name of your current job (the PY name I created here is Pythonzhushi, and the last import is the name), because the import is imported by itself in the following test, so, import name and help (name) And your file name to be consistent. For a more intuitive look at the following diagram:
Of course, it can also be imported from other file references here to use the Python common import method from which directory import what file Pythonzhushi
Of course, I still use pictures to show the following:
is not at a glance, so you can also import the comments we need to do the document, help helps us to see the file contains the classes, functions, a simple help document, similar to the Readme document a description. Finally, let's look at the masking effect:
is not simple to print out the instructions of our program document, the following steps directly can be built a text to paste the past, the completion of a Readme document description, after testing a few notes are, want to write # This comment do not write to the def in the hair to write to its upper position and the adorner similar, the opposite three quotation marks " Do not write to def outside, this also does not show the effect. Let's go and try it. Thanks for watching.