Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 503
TM. Avatar asked Dec 03 '09 19:12

TM.


People also ask

What does dir stand for in Python?

DIR does directory listings, like the Unix command ls .

What is the meaning of dir string?

for any other object: its attributes, its class's attributes, and recursively the attributes of its class's base classes. Thus, dir(string) returns the attributes of the string module while dir("someValues") returns the attributes of the str class as well as the attributes of instances thereof.

Why do we use dir?

Purpose: Displays directory of files and directories stored on disk. In addition to files and directories, DIR also displays both the volume name and amount of free storage space on the disk (if there are files stored in the current directory).

What is difference between help and dir in Python?

Originally Answered: What is the usage of help() and dir() function in Python? dir([object]) returns all attributes of the object. help(object) generate the help of the given object.


Video Answer


1 Answers

IIRC I named it after the DIR command in DOS.

like image 64
Guido van Rossum Avatar answered Oct 08 '22 23:10

Guido van Rossum