home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / p / python / !ibrowse / files / pylibi-5 (.txt) < prev    next >
GNU Info File  |  1996-11-14  |  52KB  |  1,017 lines

  1. This is Info file pylibi, produced by Makeinfo-1.55 from the input file
  2. lib.texi.
  3. This file describes the built-in types, exceptions and functions and the
  4. standard modules that come with the Python system.  It assumes basic
  5. knowledge about the Python language.  For an informal introduction to
  6. the language, see the Python Tutorial.  The Python Reference Manual
  7. gives a more formal definition of the language.  (These manuals are not
  8. yet available in INFO or Texinfo format.)
  9. Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, The
  10. Netherlands.
  11. All Rights Reserved
  12. Permission to use, copy, modify, and distribute this software and its
  13. documentation for any purpose and without fee is hereby granted,
  14. provided that the above copyright notice appear in all copies and that
  15. both that copyright notice and this permission notice appear in
  16. supporting documentation, and that the names of Stichting Mathematisch
  17. Centrum or CWI or Corporation for National Research Initiatives or CNRI
  18. not be used in advertising or publicity pertaining to distribution of
  19. the software without specific, written prior permission.
  20. While CWI is the initial source for this software, a modified version
  21. is made available by the Corporation for National Research Initiatives
  22. (CNRI) at the Internet address ftp://ftp.python.org.
  23. STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
  24. REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
  25. MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
  26. CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
  27. DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  28. PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
  29. ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
  30. THIS SOFTWARE.
  31. File: pylibi,  Node: Debugger Commands,  Next: How It Works,  Prev: The Python Debugger,  Up: The Python Debugger
  32. Debugger Commands
  33. =================
  34. The debugger recognizes the following commands.  Most commands can be
  35. abbreviated to one or two letters; e.g. "`h(elp)'" means that either
  36. "`h'" or "`help'" can be used to enter the help command (but not "`he'"
  37. or "`hel'", nor "`H'" or "`Help' or "`HELP'").  Arguments to commands
  38. must be separated by whitespace (spaces or tabs).  Optional arguments
  39. are enclosed in square brackets ("`[]'") in the command syntax; the
  40. square brackets must not be typed.  Alternatives in the command syntax
  41. are separated by a vertical bar ("`|'").
  42. Entering a blank line repeats the last command entered.  Exception: if
  43. the last command was a "`list'" command, the next 11 lines are listed.
  44. Commands that the debugger doesn't recognize are assumed to be Python
  45. statements and are executed in the context of the program being
  46. debugged.  Python statements can also be prefixed with an exclamation
  47. point ("`!'").  This is a powerful way to inspect the program being
  48. debugged; it is even possible to change a variable or call a function.
  49. When an exception occurs in such a statement, the exception name is
  50. printed but the debugger's state is not changed.
  51. h(elp) [COMMAND
  52.      ]
  53.      Without argument, print the list of available commands.  With a
  54.      COMMAND as argument, print help about that command.  "`help pdb'"
  55.      displays the full documentation file; if the environment variable
  56.      `PAGER' is defined, the file is piped through that command
  57.      instead.  Since the COMMAND argument must be an identifier, "`help
  58.      exec'" must be entered to get help on the "`!'" command.
  59. w(here)
  60.      Print a stack trace, with the most recent frame at the bottom.  An
  61.      arrow indicates the current frame, which determines the context of
  62.      most commands.
  63. d(own)
  64.      Move the current frame one level down in the stack trace (to an
  65.      older frame).
  66.      Move the current frame one level up in the stack trace (to a newer
  67.      frame).
  68. b(reak) [LINENO`|'FUNCTION
  69.      ]
  70.      With a LINENO argument, set a break there in the current file.
  71.      With a FUNCTION argument, set a break at the entry of that
  72.      function.  Without argument, list all breaks.
  73. cl(ear) [LINENO
  74.      ]
  75.      With a LINENO argument, clear that break in the current file.
  76.      Without argument, clear all breaks (but first ask confirmation).
  77. s(tep)
  78.      Execute the current line, stop at the first possible occasion
  79.      (either in a function that is called or on the next line in the
  80.      current function).
  81. n(ext)
  82.      Continue execution until the next line in the current function is
  83.      reached or it returns.  (The difference between `next' and `step'
  84.      is that `step' stops inside a called function, while `next'
  85.      executes called functions at (nearly) full speed, only stopping at
  86.      the next line in the current function.)
  87. r(eturn)
  88.      Continue execution until the current function returns.
  89. c(ont(inue))
  90.      Continue execution, only stop when a breakpoint is encountered.
  91. l(ist) [FIRST [, LAST
  92.      ]]
  93.      List source code for the current file.  Without arguments, list 11
  94.      lines around the current line or continue the previous listing.
  95.      With one argument, list 11 lines around at that line.  With two
  96.      arguments, list the given range; if the second argument is less
  97.      than the first, it is interpreted as a count.
  98. a(rgs)
  99.      Print the argument list of the current function.
  100. p EXPRESSION
  101.      Evaluate the EXPRESSION in the current context and print its
  102.      value.  (Note: `print' can also be used, but is not a debugger
  103.      command -- this executes the Python `print' statement.)
  104.      STATEMENT]
  105.      Execute the (one-line) STATEMENT in the context of the current
  106.      stack frame.  The exclamation point can be omitted unless the
  107.      first word of the statement resembles a debugger command.  To set
  108.      a global variable, you can prefix the assignment command with a
  109.      "`global'" command on the same line, e.g.:
  110.           (Pdb) global list_options; list_options = ['-l']
  111.           (Pdb)
  112. q(uit)
  113.      Quit from the debugger.  The program being executed is aborted.
  114. File: pylibi,  Node: How It Works,  Prev: Debugger Commands,  Up: The Python Debugger
  115. How It Works
  116. ============
  117. Some changes were made to the interpreter:
  118.    * sys.settrace(func) sets the global trace function
  119.    * there can also a local trace function (see later)
  120. Trace functions have three arguments: (FRAME, EVENT, ARG)
  121. FRAME
  122.      is the current stack frame
  123. EVENT
  124.      is a string: `'call'', `'line'', `'return'' or `'exception''
  125.      is dependent on the event type
  126. A trace function should return a new trace function or None.  Class
  127. methods are accepted (and most useful!) as trace methods.
  128. The events have the following meaning:
  129. `'call''
  130.      A function is called (or some other code block entered).  The
  131.      global trace function is called; arg is the argument list to the
  132.      function; the return value specifies the local trace function.
  133. `'line''
  134.      The interpreter is about to execute a new line of code (sometimes
  135.      multiple line events on one line exist).  The local trace function
  136.      is called; arg in None; the return value specifies the new local
  137.      trace function.
  138. `'return''
  139.      A function (or other code block) is about to return.  The local
  140.      trace function is called; arg is the value that will be returned.
  141.      The trace function's return value is ignored.
  142. `'exception''
  143.      An exception has occurred.  The local trace function is called;
  144.      arg is a triple (exception, value, traceback); the return value
  145.      specifies the new local trace function
  146. Note that as an exception is propagated down the chain of callers, an
  147. `'exception'' event is generated at each level.
  148. Stack frame objects have the following read-only attributes:
  149. f_code
  150.      the code object being executed
  151. f_lineno
  152.      the current line number (`-1' for `'call'' events)
  153. f_back
  154.      the stack frame of the caller, or None
  155. f_locals
  156.      dictionary containing local name bindings
  157. f_globals
  158.      dictionary containing global name bindings
  159. Code objects have the following read-only attributes:
  160. co_code
  161.      the code string
  162. co_names
  163.      the list of names used by the code
  164. co_consts
  165.      the list of (literal) constants used by the code
  166. co_filename
  167.      the filename fro