为什么“dir()”是名为“dir”在Python中?

发布于 2024-08-13 13:46:26 字数 126 浏览 4 评论 0原文

Python 中有一个名为dir 的内置函数。这用于获取对象的所有属性的列表。

我明白它的作用,但我对为什么它被称为 dir 感到困惑。这个名称与从对象获取属性有何关系?

In Python there is a built-in function called dir. This is used to get a list of all the attributes for an object.

I understand what it does, but I am confused about why it is called dir. How is this name related to getting the attributes from an object?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

乱世争霸 2024-08-20 13:46:26

IIRC 我以 DOS 中的 DIR 命令命名它。

IIRC I named it after the DIR command in DOS.

寻找我们的幸福 2024-08-20 13:46:26

它为您提供了对象所有属性的目录

这不是文件系统中使用的目录,而是标准用法:名称或数据的列表。

It gives you a directory of all attributes of an object.

This is not a directory as used in file systems, but the standard usage: a listing of names or data.

冷月断魂刀 2024-08-20 13:46:26

您正在检索一个“目录”,即某些资源中可用的所有内容的列表。

You're retrieving a "directory", a list of all of the stuff that's available in some resource.

挽容 2024-08-20 13:46:26

这个答案对于 Python 新手来说非常有用。

我正在学习 Python,今天早上我正在考虑该语言中可用的内置常量和函数。

我觉得很有趣的是你只需要记住三件事:

有一个“特殊”内置函数dir()

有一个“系统变量”__builtins__

dir(__builtins__) 输出“Python 内置世界”的视图。

那么 dir 是什么意思?我现在已经决定了:

directionections:提供用于遍历 Python Landscape 的地图。

另请参阅:

dir():显示命名空间的名称< /a>

因此,如果您愿意,您也可以让 dir 代表

display inside rubric

This answer will be most useful to those new to Python.

I am learning Python and just this morning was thinking about the builtin constants and functions that are available in the language.

I find it interesting that you only have to remember three things:

There is a 'special' builtin function dir().

There is a 'system variable' __builtins__.

dir(__builtins__) outputs a view of 'Python's builtin world'.

So what does dir mean? I've settled on this for now:

directions: supplies maps for traversing the Python Landscape.

See also:

dir(): Display a namespace's names

So if you want, you could also let dir stand for

display inside rubric

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文