June 2000
Intermediate to advanced
556 pages
8h 45m
English
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', ...
Read now
Unlock full access