The Python Dir

We've already seen 'dir' function. Let's look at it in more detail

What is dir? Is it something you say when someone says or does something stupid? Not in this context! No, here on Planet Python, the dir keyword is used to tell the programmer what attributes and methods there are in the passed in object. If you forget to pass in an object, dir will return a list of names in the current scope. As usual, this is easier to understand with a few examples.

Get hands-on with 1400+ tech skills courses.