gpt4 book ai didi

python - 注释掉的函数和 "comma splice"的作用是什么?

转载 作者:行者123 更新时间:2023-12-01 03:08:09 26 4
gpt4 key购买 nike

过去两周我一直在剖析一些代码,并且不断看到一些重复出现的主题...例如,以下内容的要点是什么...?

class eventHandler(object):
def create_event(self, event):
"""A general note here.

:tagged param event:
description
:tagged type event:
:class: `another class` # I do not understand the comma splices ( ` ).
"""
# I do not understand why it ends here with no real purpose. Perhaps I'm not catching on to something.

def next_event(self, event):
...
# Continues with the same logic from above

我在 Python 模块“watchdog”以及散布在互联网上的过去的其他模块和代码片段中看到过它。这只是一个用于记笔记的 sudo 代码格式吗?功能被取消了吗?我只是不明白某些特别的事情吗?

编辑:

Artagel 提出了一个很好的引用,我读得不够深入 PEP-0008 .

最佳答案

反引号可能对某种解析文档字符串以生成格式良好的文档的文档生成器有意义。它们在 Python 语言本身中没有任何意义。

create_event 可能是一个旨在由 eventHandler 的子类实现的方法。从语法上来说,仅文档字符串就足以充当方法的主体。如果没有文档字符串,您将需要使用 pass 语句作为“真实”正文的占位符。

def create_event(self, event):
pass

关于python - 注释掉的函数和 "comma splice"的作用是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43144305/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com