Skip to main content
Engineering LibreTexts

11.7: Debugging

  • Page ID
  • Python has some simple and rudimentary built-in documentation that can be quite helpful if you need a quick refresher to trigger your memory about the exact name of a particular method. This documentation can be viewed in the Python interpreter in interactive mode.

    You can bring up an interactive help system using help().

    >>> help()
    help> modules

    If you know what module you want to use, you can use the dir() command to find the methods in the module as follows:

    >>> import re
    >>> dir(re)
    [.. 'compile', 'copy_reg', 'error', 'escape', 'findall',
    'finditer', 'match', 'purge', 'search', 'split', 'sre_compile',
    'sre_parse', 'sub', 'subn', 'sys', 'template']

    You can also get a small amount of documentation on a particular method using the dir command.

    >>> help (
    Help on function search in module re:
    search(pattern, string, flags=0)
        Scan through string looking for a match to the pattern, returning
        a match object, or None if no match was found.

    The built-in documentation is not very extensive, but it can be helpful when you are in a hurry or don't have access to a web browser or search engine.

    • Was this article helpful?