一组Python引用的双引号?

Bri*_*ndt 4 python comments coding-style

在审查edX.org上的在线CS188.1x类中使用的一些代码(由教师编写的代码)时,我注意到重复使用一组双引号(如可能在str附近使用)用作注释.

我之前没有见过这个,也没有在PEP8中提到过我能找到的,但它看起来确实很好.任何人都可以开导我吗?

这是一个例子:

class SomeClass():
    """
    Some docstring info, using standard 'triple double quotes'
    """
    def  __init__(self):
        "This is the comment style to which I'm referring."
        some.code = foo      # Here's a normal inline comment

    def bar(self, item):
        "Here is another example of the comment style"
       return wtf
Run Code Online (Sandbox Code Playgroud)

And*_*ter 5

文档字符串是显示为在一个类,方法,函数或模块的第一个语句的任何字符串文字.在风格上,使用三重引号格式以允许更长,更好格式化的文档字符串,并引起对它们的注意以便于参考,但是任何字符串都符合条件.

文档字符串与注释不同,因为注释与程序的执行完全无关,而文档字符串在运行时通过访问对象的__doc__变量可用.