为什么'dir()'在python中命名为'dir'?
问题描述:
在Python中有一个内置函数叫做$ code> 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.
我明白了它的作用,但是我为什么被称为 DIR
。这个名字与从对象获取属性有关吗?
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?
答
它给你一个 dir 对象的所有属性的ectory。
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.