Documentation is important. The Sword of the lone nine swords, easy to the heart of the heart, write the evil sword spectrum of the robe, these are documents. Even those Daniel people want these documents, not to mention us? Therefore, the documentation is very important.
Document, it is plain that word (this is the most) and so on (note here, etc., the use of the tools are not used, including the Vim tool I edit the text) written by the text tool, contains text content but not limited to text files. A bit verbose, the purpose of wordy is to rigorous, hehe. It's better to have a more convincing definition, of course, from Wikipedia.
Copy the Code code as follows:
A software document or source code document refers to a text entity that is associated with a software system and its software engineering process. Types of documentation include software requirements documentation, design documentation, test documentation, user manuals, and more. The requirements documentation, design documentation, and test documentation are generally written by developers during the software development process, while non-process documents such as user manuals are written by specialized non-technical writers.
Early software documentation mainly refers to the user manual, according to the definition of Barker, the document is used to the software system interface elements of the design, planning and implementation of the process of recording, in order to enhance the system's usability. Forward that the software is used as a means of communication between software engineers, communication is mainly about the development of software systems. Parnas emphasizes the authority of the document, which he believes should provide an accurate description of the software system.
In summary, we can define the software documentation as:
1. Documentation is a written description of the software system;
2. The documentation should accurately describe the software system;
3. Software documentation is a means of communication between software engineers;
4. There are many types of documents, including software requirements documents, design documents, test documents, user manuals, etc.
5. There are many ways to render a document, either as a traditional written or graphic form, or as a Dynamic Web page.
So what does this Python document mean? One aspect is that every learner who learns Python,python (they are Daniel) gives us these little white things. Can we give them these Daniel to understand the meaning and usage of each function, instruction, etc. in Python?
Yes. Daniel is Daniel, they are ready, and there is more than one.
View Python Documentation
Sincere warning to all of you looking at this tutorial, to get the sublimation of the program, it is necessary to see the document. The document trumps all the tutorials and all the teachers as well as all the Daniel. Why is it? One of the reasons, we have to wait for crossing to understand, after the experience to understand the understanding.
The URL of the Python document: https://docs.python.org/2/, this is python2.x, where python3.x documents can be found.
Is there any other way besides looking at the documents on the website?
Yes, and crossing is not unfamiliar, has been used in this tutorial many times, that is, dir () and help ()
Copy the Code code as follows:
>>> dir (list)
[' __add__ ', ' __class__ ', ' __contains__ ', ' __delattr__ ', ' __delitem__ ', ' __delslice__ ', ' __doc__ ', ' __eq__ ', ' __format_ ' _ ', ' __ge__ ', ' __getattribute__ ', ' __getitem__ ', ' __getslice__ ', ' __gt__ ', ' __hash__ ', ' __iadd__ ', ' __imul__ ', ' __init_ _ ', ' __iter__ ', ' __le__ ', ' __len__ ', ' __lt__ ', ' __mul__ ', ' __ne__ ', ' __new__ ', ' __reduce__ ', ' __reduce_ex__ ', ' __repr__ ' , ' __reversed__ ', ' __rmul__ ', ' __setattr__ ', ' __setitem__ ', ' __setslice__ ', ' __sizeof__ ', ' __str__ ', ' __subclasshook__ ' ', ' append ', ' count ', ' extend ', ' index ', ' Insert ', ' pop ', ' remove ', ' reverse ', ' sort ']
>>> Help (list.__mul__)
Help on Wrapper_descriptor:
__mul__ (...)
X.__MUL__ (n) <==> x*n
This way of viewing documents, often used in interactive mode, quick and easy, please crossing must remember and use.
As already mentioned, there is one more document: The DOC,HELP call is actually the contents of this function.
Copy the Code code as follows:
>>> print (list.__mul__.__doc__) #与help (list.__mul__) shows the same content
X.__MUL__ (n) <==> x*n
>>> print (list.index.__doc__) #查看index的文档
L.index (value, [Start, [stop]]), integer-return first index of value.
Raises valueerror if the value is not present.
Add a document to your program
When you write your own program, you also want to have a similar view of the Python document features, you can look at your own program in some way to see the document, so you look more bull.
One way to do this is to have three double quotation marks or single quotes in the program you are writing to appear in pairs, with the contents of the document written in the middle.
Copy the Code code as follows:
>>> def qiwsir ():
... "" "I Like Python" ""
... print "Http://qiwsir.github.io"
...
>>> Qiwsir ()
Http://qiwsir.github.io
>>> print (qiwsir.__doc__) #用这种方法可以看自己写的函数中的文档
I like Python
>>> Help (Qiwsir) #其实就是调用__doc__显示的内容
Help on function Qiwsir in module __main__:
Qiwsir ()
I like Python
In addition, for a file, you can put the instructions in front of the file, does not affect the file code to run.
For example, there is a Python file with a. py extension that contains:
Copy the Code code as follows:
#!/usr/bin/env python
#coding: Utf-8
Import Random
Number = Random.randint (1,100)
Guess = 0
While True:
Num_input = raw_input ("Please input one integer," in 1 to 100: ")
Guess +=1
If not Num_input.isdigit ():
Print "Please input interger."
elif Int (num_input) <0 and int (num_input) >=100:
Print "The number should is in 1 to 100."
Else
If Number==int (num_input):
Print "OK, you are good. It's only%d and then you successed. " %guess
Break
Elif Number>int (num_input):
Print "Your number is more than less."
Elif number<>
Print "Your number is bigger."
Else
Print "There is something bad, I won't work"
This program, which is used in the "while to cycle" in the use of a guessing game, it is stored in a file named 205-2.py, if you want to write a document to this program, you can do so.
Copy the Code code as follows:
"""
This is a game.
I am Qiwei.
I like Python.
I am writing python articles in my website.
My website is Http://qiwsir.github.io
You can learn Python free in it.
"""
#!/usr/bin/env python
#coding: Utf-8
Import Random
Number = Random.randint (1,100)
Guess = 0
While True:
Num_input = raw_input ("Please input one integer," in 1 to 100: ")
Guess +=1
If not Num_input.isdigit ():
Print "Please input interger."
elif Int (num_input) <0 and int (num_input) >=100:
Print "The number should is in 1 to 100."
Else
If Number==int (num_input):
Print "OK, you are good. It's only%d and then you successed. " %guess
Break
Elif Number>int (num_input):
Print "Your number is more than less."
Elif number<>
Print "Your number is bigger."
Else
Print "There is something bad, I won't work"
Finally, recommend a fairly good article to share with yours faithfully:
Python introspection Guide: How to monitor your Python objects