Why is 'dir()' named 'dir' in python?

前端 未结 4 2096
醉话见心
醉话见心 2020-12-05 04:10

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

4条回答
  •  忘掉有多难
    2020-12-05 04:29

    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

提交回复
热议问题