课程: Advanced Python (2018)

今天就学习课程吧!

今天就开通帐号,24,600 门业界名师课程任您挑!

Function documentation strings

Function documentation strings - Python教程

课程: Advanced Python (2018)

Function documentation strings

- [Instructor] It's always a good idea to write documentation strings for your functions, classes, and modules. And personally, I think this is one of the great features of Python. The documentation for your program's code, as well as Python's code, is directly available as your program is being run or used by another developer. So, let's take a look at an example. Here in the terminal, I'm going to fire up the Python interpreter and then, I'm going to look at the documentation for the map function, which we learned about earlier in the course. So, to do that, all I have to do is execute the command, print, and then map, dot, underscore, underscore, doc and then two underscores. And there you can see the documentation for the map function. And as I mentioned, this works for more than just functions. It also works for classes and modules. So, I'll import the collections module that we'll be using later in the course. And I'll take a look at the docstring for that module. So, I'll…

内容