6.2. Using the dir Function

The dir function is one of the most useful functions in Python when it comes to digging around in Python's interactive mode. You provide it with the name of a module or object, and it returns lots of useful information about the contents of that module or object. In the example below, the dir command is used to list the variables and functions provided by the sys module.

CD-ROM reference=6006.txt
>>> import sys
>>> dir(sys) ['__doc__', '__name__', '__stderr__', '__stdin__', '__stdout__', 'argv', 'builtin-module-names', 'copyright', 'dllhandle', 'exc-info', 'exc-type', 'exec-prefix', 'executable', 'exit', 'getrefcount', 'hexversion', 'last-traceback', 'last-type', 'last-value', 'maxint', 'modules', 'path', 'platform', ...

Get XML Processing with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.