python / python/cpython

Add more useful help for special name in `help()`

未关闭
#137,574 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

interpreter-core type-feature
主要语言
Python
星标
77.2k
派生
35.9k
PR 合并指标
PR 指标待抓取

描述

Feature or enhancement

Proposal:

Now, use help("__name__") and some other special variables' names will still get the help from their class. I think that we can add the useful help on them. For example:

>>>help("__name__")
1. module.__name__ : if the module is run as the main module, the value is ‘_main_‘, or the name is the filename of the module. For example:if __name__ == "__main__": ...can control which code don’t run when the module is imported.

2. cls.__name__: the name of the class. It must be str.

For other special variables (such as __file__), we can alse print the similar detailed help. And I think that the sentences need to be friendly.

Also welcome to give the ideals on new ideas

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs
  • gh-137966

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先运行 help("name"),并将其当前输出与针对 namefile 提出的示例进行比较。当 help() 为所选特殊变量提供友好且有用的解释时,即表示完成;开始之前请先查看链接的 PR gh-137966。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
documentation
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。