SlideShare ist ein Scribd-Unternehmen logo
1 von 78
Downloaden Sie, um offline zu lesen
mage
   Python DEBUGGING Fundamentals

          Python Debugging Fundamentals
            Saturday, October 20, 2012
                        PyCarolinas
              UNC School of Pharmacy
                     Chapel Hill, NC
                      Chris Calloway
            University of North Carolina
          Department of Marine Sciences

                                           Programming
PyCamp™   Copyright © 2012
              Trizpug                      For The People
mage
             What Is Debugging




    A method for isolating
          program errors


                                 Programming
PyCamp™   Copyright © 2012
              Trizpug            For The People
mage
              What Is Debugging



   • Execute program one statement at
     a time
   • Inspect the state of objects bound
     to identifiers
   • Lather, rinse, repeat

                                  Programming
PyCamp™   Copyright © 2012
              Trizpug             For The People
mage
                     pdb Module




    Python's pdb module to
                 the rescue!


                                  Programming
PyCamp™   Copyright © 2012
              Trizpug             For The People
mage
      Invoking Python's Debugger




$ python -m pdb fizzbuzz.py




                             Programming
PyCamp™   Copyright © 2012
              Trizpug        For The People
mage
      Invoking Python's Debugger




                             Run a module as a script

$ python -m pdb fizzbuzz.py




                                              Programming
PyCamp™   Copyright © 2012
              Trizpug                         For The People
mage
      Invoking Python's Debugger



                             Module to run
                              as a script
$ python -m pdb fizzbuzz.py




                                       Programming
PyCamp™   Copyright © 2012
              Trizpug                  For The People
mage
      Invoking Python's Debugger



  Argument to pdb:
   script to debug
$ python -m pdb fizzbuzz.py




                             Programming
PyCamp™   Copyright © 2012
              Trizpug        For The People
mage
         Invoking Python's Debugger




$ python -m pdb fizzbuzz.py
> /Users/cbc/pycarolinas/fizzbuzz.py(7)<module>()
-> """
(Pdb)




                                      Programming
PyCamp™    Copyright © 2012
               Trizpug                For The People
mage
         Invoking Python's Debugger




$ python -m pdb fizzbuzz.py
> /Users/cbc/pycarolinas/fizzbuzz.py(7)<module>()
-> """
(Pdb)              Full path to script
                   being debugged



                                         Programming
PyCamp™    Copyright © 2012
               Trizpug                   For The People
mage
         Invoking Python's Debugger




$ python -m pdb fizzbuzz.py
> /Users/cbc/pycarolinas/fizzbuzz.py(7)<module>()
-> """
(Pdb)       Line number of next
            statement to execute



                                      Programming
PyCamp™    Copyright © 2012
               Trizpug                For The People
mage
         Invoking Python's Debugger




$ python -m pdb fizzbuzz.py
> /Users/cbc/pycarolinas/fizzbuzz.py(7)<module>()
-> """
(Pdb)                         Type of object
                              last evaluated



                                               Programming
PyCamp™    Copyright © 2012
               Trizpug                         For The People
mage
         Invoking Python's Debugger




$ python -m pdb fizzbuzz.py
> /Users/cbc/pycarolinas/fizzbuzz.py(7)<module>()
-> """
(Pdb)
            Instruction pointer to
          next statement to execute


                                      Programming
PyCamp™    Copyright © 2012
               Trizpug                For The People
mage
         Invoking Python's Debugger




$ python -m pdb fizzbuzz.py
> /Users/cbc/pycarolinas/fizzbuzz.py(7)<module>()
-> """
(Pdb)


         Debugger prompt

                                      Programming
PyCamp™    Copyright © 2012
               Trizpug                For The People
mage
                    Python's Debugger Prompt

(Pdb) help


Documented commands (type help <topic>):
========================================
EOF      cl          disable   interact     next      return   u           where
a        clear       display   j            p         retval   unalias
alias    commands    down      jump         pp        run      undisplay
args     condition   enable    l            print     rv       unt
b        cont        exit      list         q         s        until
break    continue    h         ll           quit      source   up
bt       d           help      longlist     r         step     w
c        debug       ignore    n            restart   tbreak   whatis


Miscellaneous help topics:
==========================
exec    pdb


(Pdb)



                                                                              Programming
PyCamp™                  Copyright © 2012
                             Trizpug                                          For The People
mage
            Python's Debugger Prompt

(Pdb) help list
l(ist) [first [,last] | .]


        List source code for the current file.   Without arguments,
        list 11 lines around the current line or continue the previous
        listing.    With . as argument, list 11 lines around the current
        line.   With one argument, list 11 lines starting at that line.
        With two arguments, list the given range; if the second
        argument is less than the first, it is a count.


        The current line in the current frame is indicated by "->".
        If an exception is being debugged, the line where the
        exception was originally raised or propagated is indicated by
        ">>", if it differs from the current line.
(Pdb)


                                                          Programming
PyCamp™            Copyright © 2012
                       Trizpug                            For The People
mage
            Python's Debugger Prompt

(Pdb) h l
l(ist) [first [,last] | .]


        List source code for the current file.   Without arguments,
        list 11 lines around the current line or continue the previous
        listing.    With . as argument, list 11 lines around the current
        line.   With one argument, list 11 lines starting at that line.
        With two arguments, list the given range; if the second
        argument is less than the first, it is a count.


        The current line in the current frame is indicated by "->".
        If an exception is being debugged, the line where the
        exception was originally raised or propagated is indicated by
        ">>", if it differs from the current line.
(Pdb)


                                                          Programming
PyCamp™            Copyright © 2012
                       Trizpug                            For The People
mage
                 Python's Debugger Prompt

(Pdb) l
  2       Generate the first n Fizz Buzz answers.
  3
  4       Usage:
  5
  6       > python fizzbuzz.py n
  7     -> """
  8
  9       import sys
 10
 11       def fizzbuzz(n):
 12              """
(Pdb)



                                                    Programming
PyCamp™            Copyright © 2012
                       Trizpug                      For The People
mage
                 Python's Debugger Prompt

(Pdb) l 6
  1       """
  2       Generate the first n Fizz Buzz answers.
  3
  4       Usage:
  5
  6       > python fizzbuzz.py n
  7     -> """
  8
  9       import sys
 10
 11       def fizzbuzz(n):
(Pdb)



                                                    Programming
PyCamp™            Copyright © 2012
                       Trizpug                      For The People
mage
                 Python's Debugger Prompt

(Pdb) l .
  2       Generate the first n Fizz Buzz answers.
  3
  4       Usage:
  5
  6       > python fizzbuzz.py n
  7     -> """
  8
  9       import sys
 10
 11       def fizzbuzz(n):
 12              """
(Pdb)



                                                    Programming
PyCamp™            Copyright © 2012
                       Trizpug                      For The People
mage
        Python's Debugger Prompt


(Pdb) 3 ** (1 / 2)
1.7320508075688772
(Pdb) dir()
['__builtins__', '__file__', '__name__']
(Pdb) print(__name__)
'__main__'
(Pdb)



                                  Programming
PyCamp™   Copyright © 2012
              Trizpug             For The People
mage
        Python's Debugger Prompt




(Pdb) !list
<class 'list'>
(Pdb)




                              Programming
PyCamp™   Copyright © 2012
              Trizpug         For The People
mage
              What Is Debugging



   • Execute program one statement at
     a time
   • Inspect the state of objects bound
     to identifiers
   • Lather, rinse, repeat

                                  Programming
PyCamp™   Copyright © 2012
              Trizpug             For The People
mage
                  Single Stepping




(Pdb) s
> /Users/cbc/pycarolinas/fizzbuzz.py(9)<module>()
-> import sys
(Pdb)




                                      Programming
PyCamp™    Copyright © 2012
               Trizpug                For The People
mage
                          Single Stepping

(Pdb) l
  4       Usage:
  5
  6       > python fizzbuzz.py n
  7       """
  8
  9     -> import sys
 10
 11       def fizzbuzz(n):
 12             """
 13             fizzbuzz(n) -> [first n Fizz Buzz answers]
 14             """
(Pdb)



                                                       Programming
PyCamp™            Copyright © 2012
                       Trizpug                         For The People
mage
                     Single Stepping

(Pdb) dir()
['__builtins__', '__doc__', '__file__', '__name__']
(Pdb) !print(__doc__)


Generate the first n Fizz Buzz answers.


Usage:


> python fizzbuzz.py n


(Pdb)

                                          Programming
PyCamp™       Copyright © 2012
                  Trizpug                 For The People
mage
                      Single Stepping




(Pdb) s
> /Users/cbc/pycarolinas/fizzbuzz.py(11)<module>()
-> def fizzbuzz(n):
(Pdb) dir()
['__builtins__', '__doc__', '__file__', '__name__', 'sys']
(Pdb)




                                               Programming
PyCamp™       Copyright © 2012
                  Trizpug                      For The People
mage
                         Single Stepping

(Pdb) l
  6       > python fizzbuzz.py n
  7       """
  8
  9       import sys
 10
 11     -> def fizzbuzz(n):
 12             """
 13             fizzbuzz(n) -> [first n Fizz Buzz answers]
 14             """
 15
 16             answers = []
(Pdb)



                                                       Programming
PyCamp™           Copyright © 2012
                      Trizpug                          For The People
mage
                   Single Stepping

(Pdb) l
 17       for x in range(1,n+1):
 18           answer = ""
 19           if not x%3:
 20               answer += "Fizz"
 21           if not x%5:
 22               answer += "Buzz"
 23           if not answer:
 24               answer = x
 25           answers.append(answer)
 26       return answers
 27
(Pdb)



                                       Programming
PyCamp™     Copyright © 2012
                Trizpug                For The People
mage
                        Single Stepping

(Pdb) l .
  6      > python fizzbuzz.py n
  7      """
  8
  9      import sys
 10
 11   -> def fizzbuzz(n):
 12            """
 13            fizzbuzz(n) -> [first n Fizz Buzz answers]
 14            """
 15
 16            answers = []
(Pdb)



                                                      Programming
PyCamp™          Copyright © 2012
                     Trizpug                          For The People
mage
                     Single Stepping



(Pdb) s
> /Users/cbc/pycarolinas/fizzbuzz.py(28)<module>()
-> if __name__ == '__main__':
(Pdb) dir()
['__builtins__', '__doc__', '__file__',
 '__name__', 'fizzbuzz', 'sys']
(Pdb)




                                          Programming
PyCamp™       Copyright © 2012
                  Trizpug                 For The People
mage
                            Single Stepping

(Pdb) l
 23               if not answer:
 24                      answer = x
 25               answers.append(answer)
 26           return answers
 27
 28     -> if __name__ == '__main__':
 29           try:
 30               if len(sys.argv) != 2:
 31                      raise ValueError("Incorrect number of arguments")
 32               answers = fizzbuzz(int(sys.argv[1]))
 33               print(" ".join([str(answer) for answer in answers]))
(Pdb)




                                                            Programming
PyCamp™              Copyright © 2012
                         Trizpug                            For The People
mage
                     Single Stepping

(Pdb) s
> /Users/cbc/pycarolinas/fizzbuzz.py(29)<module>()
-> try:
(Pdb) s
> /Users/cbc/pycarolinas/fizzbuzz.py(30)<module>()
-> if len(sys.argv) != 2:
(Pdb) s
> /Users/cbc/pycarolinas/fizzbuzz.py(31)<module>()
-> raise ValueError("Incorrect number of arguments")
(Pdb) s
ValueError: Incorrect number of arguments
> /Users/cbc/pycarolinas/fizzbuzz.py(31)<module>()
-> raise ValueError("Incorrect number of arguments")
(Pdb)

                                                     Programming
PyCamp™       Copyright © 2012
                  Trizpug                            For The People
mage
                     Single Stepping




(Pdb) s
> /Users/cbc/pycarolinas/fizzbuzz.py(34)<module>()
-> except:
(Pdb) s
> /Users/cbc/pycarolinas/fizzbuzz.py(35)<module>()
-> print(__doc__)
(Pdb)




                                                     Programming
PyCamp™       Copyright © 2012
                  Trizpug                            For The People
mage
                     Single Stepping

(Pdb) s


Generate the first n Fizz Buzz answers.


Usage:


> python fizzbuzz.py n


--Return--
> /Users/cbc/pycarolinas/fizzbuzz.py(35)<module>()->None
-> print(__doc__)
(Pdb)




                                                   Programming
PyCamp™       Copyright © 2012
                  Trizpug                          For The People
mage
                     Single Stepping




(Pdb) s
--Return--
> <string>(1)<module>()->None
(Pdb) l
[EOF]
(Pdb)




                                       Programming
PyCamp™       Copyright © 2012
                  Trizpug              For The People
mage
                     Single Stepping


(Pdb) s
> /opt/python330/lib/python3.3/bdb.py(409)run()
-> self.quitting = True
(Pdb) s
The program finished and will be restarted
> /Users/cbc/pycarolinas/fizzbuzz.py(7)<module>()
-> """
(Pdb) dir()
['__builtins__', '__file__', '__name__']
(Pdb)




                                                    Programming
PyCamp™       Copyright © 2012
                  Trizpug                           For The People
mage
                 Single Stepping




(Pdb) q
$




                                   Programming
PyCamp™   Copyright © 2012
              Trizpug              For The People
mage
      Invoking Python's Debugger




$ python -m pdb fizzbuzz.py 100




                             Programming
PyCamp™   Copyright © 2012
              Trizpug        For The People
mage
         Invoking Python's Debugger




$ python -m pdb fizzbuzz.py 100
> /Users/cbc/pycarolinas/fizzbuzz.py(7)<module>()
-> """
(Pdb)




                                      Programming
PyCamp™    Copyright © 2012
               Trizpug                For The People
mage
               Python's Debugger Prompt

(Pdb) l
  2       Generate the first n Fizz Buzz answers.
  3
  4       Usage:
  5
  6       > python fizzbuzz.py n
  7   -> """
  8
  9       import sys
 10
 11       def fizzbuzz(n):
 12            """
(Pdb)




                                                    Programming
PyCamp™              Copyright © 2012
                         Trizpug                    For The People
mage
          Python's Debugger Prompt

(Pdb) l
 13       fizzbuzz(n) -> [first n Fizz Buzz answers]
 14       """
 15
 16       answers = []
 17       for x in range(1,n+1):
 18             answer = ""
 19             if not x%3:
 20                 answer += "Fizz"
 21             if not x%5:
 22                 answer += "Buzz"
 23             if not answer:
(Pdb)




                                                       Programming
PyCamp™         Copyright © 2012
                    Trizpug                            For The People
mage
              Python's Debugger Prompt

(Pdb) l
 24                      answer = x
 25               answers.append(answer)
 26           return answers
 27
 28       if __name__ == '__main__':
 29           try:
 30                  if len(sys.argv) != 2:
 31                      raise ValueError("Incorrect number of arguments")
 32               answers = fizzbuzz(int(sys.argv[1]))
 33               print(" ".join([str(answer) for answer in answers]))
 34           except:
(Pdb)




                                                            Programming
PyCamp™              Copyright © 2012
                         Trizpug                            For The People
mage
                     Setting a Breakpoint

(Pdb) b 30
Breakpoint 1 at /Users/cbc/pycarolinas/fizzbuzz.py:30
(Pdb) l 30
 25              answers.append(answer)
 26          return answers
 27
 28     if __name__ == '__main__':
 29          try:
 30 B               if len(sys.argv) != 2:
 31                     raise ValueError("Incorrect number of arguments")
 32              answers = fizzbuzz(int(sys.argv[1]))
 33              print(" ".join([str(answer) for answer in answers]))
 34          except:
 35              print(__doc__)
(Pdb)


                                                           Programming
PyCamp™             Copyright © 2012
                        Trizpug                            For The People
mage
                        Setting a Breakpoint

(Pdb) l .
  2       Generate the first n Fizz Buzz answers.
  3
  4       Usage:
  5
  6       > python fizzbuzz.py n
  7     -> """
  8
  9       import sys
 10
 11       def fizzbuzz(n):
 12              """
(Pdb)




                                                    Programming
PyCamp™                Copyright © 2012
                           Trizpug                  For The People
mage
                        Setting a Breakpoint

(Pdb) c
> /Users/cbc/pycarolinas/fizzbuzz.py(30)<module>()
-> if len(sys.argv) != 2:
(Pdb) l
 25               answers.append(answer)
 26           return answers
 27
 28       if __name__ == '__main__':
 29           try:
 30 B->              if len(sys.argv) != 2:
 31                     raise ValueError("Incorrect number of arguments")
 32               answers = fizzbuzz(int(sys.argv[1]))
 33               print(" ".join([str(answer) for answer in answers]))
 34           except:
 35               print(__doc__)
(Pdb)


                                                                 Programming
PyCamp™               Copyright © 2012
                          Trizpug                                For The People
mage
          Stepping Into a Function



(Pdb) len(sys.argv)
2
(Pdb) s
> /Users/cbc/pycarolinas/fizzbuzz.py(32)<module>()
-> answers = fizzbuzz(int(sys.argv[1]))
(Pdb)




                                          Programming
PyCamp™    Copyright © 2012
               Trizpug                    For The People
mage
                      Stepping Into a Function

(Pdb) s
--Call--
> /Users/cbc/pycarolinas/fizzbuzz.py(11)fizzbuzz()
-> def fizzbuzz(n):
(Pdb) l
  6       > python fizzbuzz.py n
  7       """
  8
  9       import sys
 10
 11     -> def fizzbuzz(n):
 12             """
 13             fizzbuzz(n) -> [first n Fizz Buzz answers]
 14             """
 15
 16             answers = []
(Pdb)




                                                             Programming
PyCamp™                Copyright © 2012
                           Trizpug                           For The People
mage
            Stepping Into a Function

(Pdb) p n
100
(Pdb) s
> /Users/cbc/pycarolinas/fizzbuzz.py(16)fizzbuzz()
-> answers = []
(Pdb) s
> /Users/cbc/pycarolinas/fizzbuzz.py(17)fizzbuzz()
-> for x in range(1,n+1):
(Pdb) s
> /Users/cbc/pycarolinas/fizzbuzz.py(18)fizzbuzz()
-> answer = ""
(Pdb)

                                           Programming
PyCamp™      Copyright © 2012
                 Trizpug                   For The People
mage
              Stepping Into a Function

(Pdb) l
 13          fizzbuzz(n) -> [first n Fizz Buzz answers]
 14          """
 15
 16          answers = []
 17          for x in range(1,n+1):
 18     ->         answer = ""
 19                if not x%3:
 20                    answer += "Fizz"
 21                if not x%5:
 22                    answer += "Buzz"
 23                if not answer:
(Pdb)




                                                          Programming
PyCamp™            Copyright © 2012
                       Trizpug                            For The People
mage
          Stepping Into a Function

(Pdb) dir()
['answers', 'n', 'x']
(Pdb) where
  /opt/python330/lib/python3.3/bdb.py(405)run()
-> exec(cmd, globals, locals)
  <string>(1)<module>()
  /Users/cbc/pycarolinas/fizzbuzz.py(32)<module>()
-> answers = fizzbuzz(int(sys.argv[1]))
> /Users/cbc/pycarolinas/fizzbuzz.py(18)fizzbuzz()
-> answer = ""
(Pdb)



                                           Programming
PyCamp™       Copyright © 2012
                  Trizpug                  For The People
mage
                       Stack Frames

(Pdb) up
> /Users/cbc/pycarolinas/fizzbuzz.py(32)<module>()
-> answers = fizzbuzz(int(sys.argv[1]))
(Pdb) dir()
['__builtins__', '__doc__', '__file__',
 '__name__', 'fizzbuzz', 'sys']
(Pdb) down
> /Users/cbc/pycarolinas/fizzbuzz.py(18)fizzbuzz()
-> answer = ""
(Pdb) down
*** Newest frame
(Pdb)

                                           Programming
PyCamp™       Copyright © 2012
                  Trizpug                  For The People
mage
            Stepping Into a Function

(Pdb) l
 13        fizzbuzz(n) -> [first n Fizz Buzz answers]
 14        """
 15
 16        answers = []
 17        for x in range(1,n+1):
 18   ->         answer = ""
 19              if not x%3:
 20                  answer += "Fizz"
 21              if not x%5:
 22                  answer += "Buzz"
 23              if not answer:
(Pdb)




                                                        Programming
PyCamp™          Copyright © 2012
                     Trizpug                            For The People
mage
            Stepping Into a Function

(Pdb) c
1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17
Fizz 19 Buzz Fizz 22 23 Fizz Buzz 26 Fizz 28 29 FizzBuzz 31 32
Fizz 34 Buzz Fizz 37 38 Fizz Buzz 41 Fizz 43 44 FizzBuzz 46 47
Fizz 49 Buzz Fizz 52 53 Fizz Buzz 56 Fizz 58 59 FizzBuzz 61 62
Fizz 64 Buzz Fizz 67 68 Fizz Buzz 71 Fizz 73 74 FizzBuzz 76 77
Fizz 79 Buzz Fizz 82 83 Fizz Buzz 86 Fizz 88 89 FizzBuzz 91 92
Fizz 94 Buzz Fizz 97 98 Fizz Buzz
The program finished and will be restarted
> /Users/cbc/pycarolinas/fizzbuzz.py(7)<module>()
-> """
(Pdb)




                                                    Programming
PyCamp™       Copyright © 2012
                  Trizpug                           For The People
mage
                     Listing Breakpoints


(Pdb) b
Num Type           Disp Enb     Where
1   breakpoint     keep yes     at /Users/cbc/pycarolinas/fizzbuzz.py:30
           breakpoint already hit 1 time
(Pdb) c
> /Users/cbc/pycarolinas/fizzbuzz.py(30)<module>()
-> if len(sys.argv) != 2:
(Pdb) s
> /Users/cbc/pycarolinas/fizzbuzz.py(32)<module>()
-> answers = fizzbuzz(int(sys.argv[1]))
(Pdb)




                                                           Programming
PyCamp™            Copyright © 2012
                       Trizpug                             For The People
mage
            Stepping Over a Function


(Pdb) n
> /Users/cbc/pycarolinas/fizzbuzz.py(33)<module>()
-> print(" ".join([str(answer) for answer in answers]))
(Pdb) pp answers
[1,
 2,
 'Fizz',
...
 98,
 'Fizz',
 'Buzz']
(Pdb)



                                                     Programming
PyCamp™       Copyright © 2012
                  Trizpug                            For The People
mage
            Stepping Over a Function

(Pdb) c
1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17
Fizz 19 Buzz Fizz 22 23 Fizz Buzz 26 Fizz 28 29 FizzBuzz 31 32
Fizz 34 Buzz Fizz 37 38 Fizz Buzz 41 Fizz 43 44 FizzBuzz 46 47
Fizz 49 Buzz Fizz 52 53 Fizz Buzz 56 Fizz 58 59 FizzBuzz 61 62
Fizz 64 Buzz Fizz 67 68 Fizz Buzz 71 Fizz 73 74 FizzBuzz 76 77
Fizz 79 Buzz Fizz 82 83 Fizz Buzz 86 Fizz 88 89 FizzBuzz 91 92
Fizz 94 Buzz Fizz 97 98 Fizz Buzz
The program finished and will be restarted
> /Users/cbc/pycarolinas/fizzbuzz.py(7)<module>()
-> """
(Pdb)




                                                    Programming
PyCamp™       Copyright © 2012
                  Trizpug                           For The People
mage
                Stepping Over a Function


(Pdb) c
> /Users/cbc/pycarolinas/fizzbuzz.py(30)<module>()
-> if len(sys.argv) != 2:
(Pdb) b
Num Type           Disp Enb     Where
1   breakpoint     keep yes     at /Users/cbc/pycarolinas/fizzbuzz.py:30
           breakpoint already hit 3 times
(Pdb) s
> /Users/cbc/pycarolinas/fizzbuzz.py(32)<module>()
-> answers = fizzbuzz(int(sys.argv[1]))
(Pdb)




                                                           Programming
PyCamp™            Copyright © 2012
                       Trizpug                             For The People
mage
             Stepping Over a Function

(Pdb) s
--Call--
> /Users/cbc/pycarolinas/fizzbuzz.py(11)fizzbuzz()
-> def fizzbuzz(n):
(Pdb) s
> /Users/cbc/pycarolinas/fizzbuzz.py(16)fizzbuzz()
-> answers = []
(Pdb) s
> /Users/cbc/pycarolinas/fizzbuzz.py(17)fizzbuzz()
-> for x in range(1,n+1):
(Pdb) s
> /Users/cbc/pycarolinas/fizzbuzz.py(18)fizzbuzz()
-> answer = ""
(Pdb)



                                                     Programming
PyCamp™           Copyright © 2012
                      Trizpug                        For The People
mage
             Stepping Over a Function



(Pdb) r
--Return--
> /Users/cbc/pycarolinas/fizzbuzz.py(26)fizzbuzz()->
  [1, 2, 'Fizz', 4, 'Buzz', 'Fizz', ...]
-> return answers
(Pdb)




                                           Programming
PyCamp™       Copyright © 2012
                  Trizpug                  For The People
mage
   Stepping Over a List Comprehension

(Pdb) s
> /Users/cbc/pycarolinas/fizzbuzz.py(33)<module>()
-> print(" ".join([str(answer) for answer in answers]))
(Pdb) s
--Call--
> /Users/cbc/pycarolinas/fizzbuzz.py(33)<listcomp>()
-> print(" ".join([str(answer) for answer in answers]))
(Pdb) s
> /Users/cbc/pycarolinas/fizzbuzz.py(33)<listcomp>()
-> print(" ".join([str(answer) for answer in answers]))
(Pdb)



                                           Programming
PyCamp™     Copyright © 2012
                Trizpug                    For The People
mage
   Stepping Over a List Comprehension




(Pdb) r
--Return--
> /Users/cbc/pycarolinas/fizzbuzz.py(33)<listcomp>()->
  ['1', '2', 'Fizz', '4', 'Buzz', 'Fizz', ...]
-> print(" ".join([str(answer) for answer in answers]))
(Pdb)




                                                 Programming
PyCamp™      Copyright © 2012
                 Trizpug                         For The People
mage
                    Clear Breakpoints



(Pdb) h clear
cl(ear) filename:lineno
cl(ear) [bpnumber [bpnumber...]]
        With a space separated list of breakpoint numbers, clear
        those breakpoints.   Without argument, clear all breaks (but
        first ask confirmation).   With a filename:lineno argument,
        clear all breaks at that line in that file.
(Pdb)




                                                        Programming
PyCamp™         Copyright © 2012
                    Trizpug                             For The People
mage
                    Disable Breakpoints



(Pdb) h disable
disable bpnumber [bpnumber ...]
        Disables the breakpoints given as a space separated list of
        breakpoint numbers.      Disabling a breakpoint means it cannot
        cause the program to stop execution, but unlike clearing a
        breakpoint, it remains in the list of breakpoints and can be
        (re-)enabled.
(Pdb)




                                                           Programming
PyCamp™           Copyright © 2012
                      Trizpug                              For The People
mage
                    Enable Breakpoints




(Pdb) h enable
enable bpnumber [bpnumber ...]
        Enables the breakpoints given as a space separated list of
        breakpoint numbers.
(Pdb)




                                                       Programming
PyCamp™          Copyright © 2012
                     Trizpug                           For The People
mage
           Monitor Objects for Changes




(Pdb) h display
display [expression]


        Display the value of the expression if it changed, each time execution
        stops in the current frame.


        Without expression, list all display expressions for the current frame.
(Pdb)




                                                                    Programming
PyCamp™            Copyright © 2012
                       Trizpug                                      For The People
mage
             Conditional Breakpoints




(Pdb) h condition
condition bpnumber [condition]
        Set a new condition for the breakpoint, an expression which
        must evaluate to true before the breakpoint is honored.   If
        condition is absent, any existing condition is removed; i.e.,
        the breakpoint is made unconditional.
(Pdb)




                                                       Programming
PyCamp™         Copyright © 2012
                    Trizpug                            For The People
mage
                 Skip Over Breakpoints



(Pdb) h ignore
ignore bpnumber [count]
        Set the ignore count for the given breakpoint number.    If
        count is omitted, the ignore count is set to 0.    A breakpoint
        becomes active when the ignore count is zero.   When non-zero,
        the count is decremented each time the breakpoint is reached
        and the breakpoint is not disabled and any associated
        condition evaluates to true.
(Pdb)




                                                          Programming
PyCamp™          Copyright © 2012
                     Trizpug                              For The People
mage
                       Debugger Macros



(Pdb) help alias
alias [name [command [parameter parameter ...] ]]
       Create an alias called 'name' that executes 'command'.     The
       command must *not* be enclosed in quotes.    Replaceable
       parameters can be indicated by %1, %2, and so on, while %* is
       replaced by all the parameters.   If no command is given, the
       current alias for name is shown. If no name is given, all
       aliases are listed.




                                                        Programming
PyCamp™            Copyright © 2012
                       Trizpug                          For The People
mage
                  One Time Breakpoints




(Pdb) h tbreak
tbreak [ ([filename:]lineno | function) [, condition] ]
        Same arguments as break, but sets a temporary breakpoint: it
        is automatically deleted when first hit.
(Pdb)




                                                          Programming
PyCamp™          Copyright © 2012
                     Trizpug                              For The People
mage
             What Is Debugging



   • Execute entire program one step at
     the time
   • Execute only suspect portions of
     program
   • Isolate suspect portions of program

                                 Programming
PyCamp™   Copyright © 2012
              Trizpug            For The People
mage
                       Setting a Trace



if __name__ == '__main__':
    try:
        if len(sys.argv) != 2:
              import pdb; pdb.set_trace()
              raise ValueError("Incorrect number of arguments")
        answers = fizzbuzz(int(sys.argv[1]))
        print(" ".join([str(answer) for answer in answers]))
    except:
        print(__doc__)




                                                     Programming
PyCamp™         Copyright © 2012
                    Trizpug                          For The People
mage
                  Setting a Trace




$ python fizzbuzzNG.py
> /Users/cbc/pycarolinas/fizzbuzzNG.py(32)<module>()
-> raise ValueError("Incorrect number of arguments")
(Pdb)




                                        Programming
PyCamp™    Copyright © 2012
               Trizpug                  For The People
mage
             Post-mortem Debugging




if __name__ == '__main__':
    if len(sys.argv) != 2:
        raise ValueError("Incorrect number of arguments")
    answers = fizzbuzz(int(sys.argv[1]))
    print(" ".join([str(answer) for answer in answers]))




                                                   Programming
PyCamp™       Copyright © 2012
                  Trizpug                          For The People
mage
             Post-mortem Debugging




$ python -i fizzbuzzNG2.py
Traceback (most recent call last):
  File "fizzbuzzNG2.py", line 30, in <module>
      raise ValueError("Incorrect number of arguments")
ValueError: Incorrect number of arguments
>>>




                                             Programming
PyCamp™       Copyright © 2012
                  Trizpug                    For The People
mage
           Post-mortem Debugging




>>> import pdb; pdb.pm()
> /Users/cbc/pycarolinas/fizzbuzzNG2.py(30)<module>()
-> raise ValueError("Incorrect number of arguments")
(Pdb)




                                           Programming
PyCamp™     Copyright © 2012
                Trizpug                    For The People
mage
                 Debugger Runner

>>> import fizzbuzz
>>> import pdb
>>> pdb.run('fizzbuzz.fizzbuzz(100)')
> <string>(1)<module>()
(Pdb) s
--Call--
> /Users/cbc/pycarolinas/fizzbuzz.py(11)fizzbuzz()
-> def fizzbuzz(n):
(Pdb)




                                        Programming
PyCamp™    Copyright © 2012
               Trizpug                  For The People
mage
   Python DEBUGGING Fundamentals




     Questions?
                 cbc@chriscalloway.org
     http://drunkenpython.org/pycarolinas.zip
      http://docs.python.org/py3k/library/pdb.html#module-pdb



                                                       Programming
PyCamp™    Copyright © 2012
               Trizpug                                 For The People

Weitere ähnliche Inhalte

Was ist angesagt?

Object Oriented Programming in Python
Object Oriented Programming in PythonObject Oriented Programming in Python
Object Oriented Programming in PythonSujith Kumar
 
Iterarators and generators in python
Iterarators and generators in pythonIterarators and generators in python
Iterarators and generators in pythonSarfaraz Ghanta
 
Python Lambda Function
Python Lambda FunctionPython Lambda Function
Python Lambda FunctionMd Soyaib
 
Introduction to django framework
Introduction to django frameworkIntroduction to django framework
Introduction to django frameworkKnoldus Inc.
 
Python Data Structures and Algorithms.pptx
Python Data Structures and Algorithms.pptxPython Data Structures and Algorithms.pptx
Python Data Structures and Algorithms.pptxShreyasLawand
 
Looping Statements and Control Statements in Python
Looping Statements and Control Statements in PythonLooping Statements and Control Statements in Python
Looping Statements and Control Statements in PythonPriyankaC44
 
Python tutorial for beginners - Tib academy
Python tutorial for beginners - Tib academyPython tutorial for beginners - Tib academy
Python tutorial for beginners - Tib academyTIB Academy
 
Python 3 Programming Language
Python 3 Programming LanguagePython 3 Programming Language
Python 3 Programming LanguageTahani Al-Manie
 
programming with python ppt
programming with python pptprogramming with python ppt
programming with python pptPriyanka Pradhan
 
A Basic Django Introduction
A Basic Django IntroductionA Basic Django Introduction
A Basic Django IntroductionGanga Ram
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in pythoneShikshak
 
Python Basics
Python BasicsPython Basics
Python BasicsPooja B S
 

Was ist angesagt? (20)

Python Basics.pdf
Python Basics.pdfPython Basics.pdf
Python Basics.pdf
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Object Oriented Programming in Python
Object Oriented Programming in PythonObject Oriented Programming in Python
Object Oriented Programming in Python
 
Iterarators and generators in python
Iterarators and generators in pythonIterarators and generators in python
Iterarators and generators in python
 
Python Lambda Function
Python Lambda FunctionPython Lambda Function
Python Lambda Function
 
Threads in python
Threads in pythonThreads in python
Threads in python
 
Introduction to django framework
Introduction to django frameworkIntroduction to django framework
Introduction to django framework
 
Python Data Structures and Algorithms.pptx
Python Data Structures and Algorithms.pptxPython Data Structures and Algorithms.pptx
Python Data Structures and Algorithms.pptx
 
Looping Statements and Control Statements in Python
Looping Statements and Control Statements in PythonLooping Statements and Control Statements in Python
Looping Statements and Control Statements in Python
 
Python tutorial for beginners - Tib academy
Python tutorial for beginners - Tib academyPython tutorial for beginners - Tib academy
Python tutorial for beginners - Tib academy
 
Python exception handling
Python   exception handlingPython   exception handling
Python exception handling
 
Python 3 Programming Language
Python 3 Programming LanguagePython 3 Programming Language
Python 3 Programming Language
 
programming with python ppt
programming with python pptprogramming with python ppt
programming with python ppt
 
Python introduction
Python introductionPython introduction
Python introduction
 
A Basic Django Introduction
A Basic Django IntroductionA Basic Django Introduction
A Basic Django Introduction
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
 
Python Basics
Python BasicsPython Basics
Python Basics
 
Python ppt
Python pptPython ppt
Python ppt
 
Python GUI
Python GUIPython GUI
Python GUI
 
Python programming
Python  programmingPython  programming
Python programming
 

Andere mochten auch

Debugging of (C)Python applications
Debugging of (C)Python applicationsDebugging of (C)Python applications
Debugging of (C)Python applicationsRoman Podoliaka
 
Python debugging techniques
Python debugging techniquesPython debugging techniques
Python debugging techniquesTuomas Suutari
 
Python Programming Essentials - M21 - Exception Handling
Python Programming Essentials - M21 - Exception HandlingPython Programming Essentials - M21 - Exception Handling
Python Programming Essentials - M21 - Exception HandlingP3 InfoTech Solutions Pvt. Ltd.
 
Python - File operations & Data parsing
Python - File operations & Data parsingPython - File operations & Data parsing
Python - File operations & Data parsingFelix Z. Hoffmann
 
Python Programming - XI. String Manipulation and Regular Expressions
Python Programming - XI. String Manipulation and Regular ExpressionsPython Programming - XI. String Manipulation and Regular Expressions
Python Programming - XI. String Manipulation and Regular ExpressionsRanel Padon
 
Python Programming - XII. File Processing
Python Programming - XII. File ProcessingPython Programming - XII. File Processing
Python Programming - XII. File ProcessingRanel Padon
 
2100. 4 класс Урок 2.58. Решение задач
2100. 4 класс Урок 2.58. Решение задач2100. 4 класс Урок 2.58. Решение задач
2100. 4 класс Урок 2.58. Решение задачavtatuzova
 

Andere mochten auch (9)

Debugging of (C)Python applications
Debugging of (C)Python applicationsDebugging of (C)Python applications
Debugging of (C)Python applications
 
Libraries
LibrariesLibraries
Libraries
 
Python debugging techniques
Python debugging techniquesPython debugging techniques
Python debugging techniques
 
Python Programming Essentials - M21 - Exception Handling
Python Programming Essentials - M21 - Exception HandlingPython Programming Essentials - M21 - Exception Handling
Python Programming Essentials - M21 - Exception Handling
 
Python Programming Essentials - M7 - Strings
Python Programming Essentials - M7 - StringsPython Programming Essentials - M7 - Strings
Python Programming Essentials - M7 - Strings
 
Python - File operations & Data parsing
Python - File operations & Data parsingPython - File operations & Data parsing
Python - File operations & Data parsing
 
Python Programming - XI. String Manipulation and Regular Expressions
Python Programming - XI. String Manipulation and Regular ExpressionsPython Programming - XI. String Manipulation and Regular Expressions
Python Programming - XI. String Manipulation and Regular Expressions
 
Python Programming - XII. File Processing
Python Programming - XII. File ProcessingPython Programming - XII. File Processing
Python Programming - XII. File Processing
 
2100. 4 класс Урок 2.58. Решение задач
2100. 4 класс Урок 2.58. Решение задач2100. 4 класс Урок 2.58. Решение задач
2100. 4 класс Урок 2.58. Решение задач
 

Ähnlich wie Python Debugging Fundamentals

Python Testing Fundamentals
Python Testing FundamentalsPython Testing Fundamentals
Python Testing Fundamentalscbcunc
 
Evdokimov python arsenal for re
Evdokimov   python arsenal for reEvdokimov   python arsenal for re
Evdokimov python arsenal for reDefconRussia
 
Build microservice with gRPC in golang
Build microservice with gRPC in golangBuild microservice with gRPC in golang
Build microservice with gRPC in golangTing-Li Chou
 
When Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
When Good Code Goes Bad: Tools and Techniques for Troubleshooting PloneWhen Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
When Good Code Goes Bad: Tools and Techniques for Troubleshooting PloneDavid Glick
 
Boost.Python - domesticating the snake
Boost.Python - domesticating the snakeBoost.Python - domesticating the snake
Boost.Python - domesticating the snakeSławomir Zborowski
 
Pipfile, pipenv, pip… what?!
Pipfile, pipenv, pip… what?!Pipfile, pipenv, pip… what?!
Pipfile, pipenv, pip… what?!Ivan Chernoff
 
Euro python2011 High Performance Python
Euro python2011 High Performance PythonEuro python2011 High Performance Python
Euro python2011 High Performance PythonIan Ozsvald
 
PyParis2017 / Function-as-a-service - a pythonic perspective on severless com...
PyParis2017 / Function-as-a-service - a pythonic perspective on severless com...PyParis2017 / Function-as-a-service - a pythonic perspective on severless com...
PyParis2017 / Function-as-a-service - a pythonic perspective on severless com...Pôle Systematic Paris-Region
 
MongoDB & Hadoop: Flexible Hourly Batch Processing Model
MongoDB & Hadoop: Flexible Hourly Batch Processing ModelMongoDB & Hadoop: Flexible Hourly Batch Processing Model
MongoDB & Hadoop: Flexible Hourly Batch Processing ModelTakahiro Inoue
 
Debugging PHP with xDebug inside of Eclipse PDT 2.1
Debugging PHP with xDebug inside of Eclipse PDT 2.1Debugging PHP with xDebug inside of Eclipse PDT 2.1
Debugging PHP with xDebug inside of Eclipse PDT 2.1Bastian Feder
 
Debugging Hung Python Processes With GDB
Debugging Hung Python Processes With GDBDebugging Hung Python Processes With GDB
Debugging Hung Python Processes With GDBbmbouter
 
MPL: modular pipeline library - Dynamic Talks Milwaukee 4/11/2019
MPL: modular pipeline library - Dynamic Talks Milwaukee 4/11/2019MPL: modular pipeline library - Dynamic Talks Milwaukee 4/11/2019
MPL: modular pipeline library - Dynamic Talks Milwaukee 4/11/2019Grid Dynamics
 
The story of migrating from Java to Python
The story of migrating from Java to PythonThe story of migrating from Java to Python
The story of migrating from Java to Pythonivohoubrechts1
 
Pycvf
PycvfPycvf
Pycvftranx
 
Generating Assertion Code from OCL: A Transformational Approach Based on Simi...
Generating Assertion Code from OCL: A Transformational Approach Based on Simi...Generating Assertion Code from OCL: A Transformational Approach Based on Simi...
Generating Assertion Code from OCL: A Transformational Approach Based on Simi...Shinpei Hayashi
 
2004 Esug Prototalk
2004 Esug Prototalk2004 Esug Prototalk
2004 Esug Prototalkbergel
 

Ähnlich wie Python Debugging Fundamentals (20)

Python Testing Fundamentals
Python Testing FundamentalsPython Testing Fundamentals
Python Testing Fundamentals
 
Evdokimov python arsenal for re
Evdokimov   python arsenal for reEvdokimov   python arsenal for re
Evdokimov python arsenal for re
 
PyPy London Demo Evening 2013
PyPy London Demo Evening 2013PyPy London Demo Evening 2013
PyPy London Demo Evening 2013
 
Build microservice with gRPC in golang
Build microservice with gRPC in golangBuild microservice with gRPC in golang
Build microservice with gRPC in golang
 
When Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
When Good Code Goes Bad: Tools and Techniques for Troubleshooting PloneWhen Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
When Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
 
Boost.Python - domesticating the snake
Boost.Python - domesticating the snakeBoost.Python - domesticating the snake
Boost.Python - domesticating the snake
 
Pipfile, pipenv, pip… what?!
Pipfile, pipenv, pip… what?!Pipfile, pipenv, pip… what?!
Pipfile, pipenv, pip… what?!
 
Euro python2011 High Performance Python
Euro python2011 High Performance PythonEuro python2011 High Performance Python
Euro python2011 High Performance Python
 
PyParis2017 / Function-as-a-service - a pythonic perspective on severless com...
PyParis2017 / Function-as-a-service - a pythonic perspective on severless com...PyParis2017 / Function-as-a-service - a pythonic perspective on severless com...
PyParis2017 / Function-as-a-service - a pythonic perspective on severless com...
 
Numba lightning
Numba lightningNumba lightning
Numba lightning
 
MongoDB & Hadoop: Flexible Hourly Batch Processing Model
MongoDB & Hadoop: Flexible Hourly Batch Processing ModelMongoDB & Hadoop: Flexible Hourly Batch Processing Model
MongoDB & Hadoop: Flexible Hourly Batch Processing Model
 
Debugging PHP with xDebug inside of Eclipse PDT 2.1
Debugging PHP with xDebug inside of Eclipse PDT 2.1Debugging PHP with xDebug inside of Eclipse PDT 2.1
Debugging PHP with xDebug inside of Eclipse PDT 2.1
 
Debugging Hung Python Processes With GDB
Debugging Hung Python Processes With GDBDebugging Hung Python Processes With GDB
Debugging Hung Python Processes With GDB
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
MPL: modular pipeline library - Dynamic Talks Milwaukee 4/11/2019
MPL: modular pipeline library - Dynamic Talks Milwaukee 4/11/2019MPL: modular pipeline library - Dynamic Talks Milwaukee 4/11/2019
MPL: modular pipeline library - Dynamic Talks Milwaukee 4/11/2019
 
The story of migrating from Java to Python
The story of migrating from Java to PythonThe story of migrating from Java to Python
The story of migrating from Java to Python
 
Pycvf
PycvfPycvf
Pycvf
 
Generating Assertion Code from OCL: A Transformational Approach Based on Simi...
Generating Assertion Code from OCL: A Transformational Approach Based on Simi...Generating Assertion Code from OCL: A Transformational Approach Based on Simi...
Generating Assertion Code from OCL: A Transformational Approach Based on Simi...
 
2004 Esug Prototalk
2004 Esug Prototalk2004 Esug Prototalk
2004 Esug Prototalk
 
Python+gradle
Python+gradlePython+gradle
Python+gradle
 

Python Debugging Fundamentals

  • 1. mage Python DEBUGGING Fundamentals Python Debugging Fundamentals Saturday, October 20, 2012 PyCarolinas UNC School of Pharmacy Chapel Hill, NC Chris Calloway University of North Carolina Department of Marine Sciences Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 2. mage What Is Debugging A method for isolating program errors Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 3. mage What Is Debugging • Execute program one statement at a time • Inspect the state of objects bound to identifiers • Lather, rinse, repeat Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 4. mage pdb Module Python's pdb module to the rescue! Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 5. mage Invoking Python's Debugger $ python -m pdb fizzbuzz.py Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 6. mage Invoking Python's Debugger Run a module as a script $ python -m pdb fizzbuzz.py Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 7. mage Invoking Python's Debugger Module to run as a script $ python -m pdb fizzbuzz.py Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 8. mage Invoking Python's Debugger Argument to pdb: script to debug $ python -m pdb fizzbuzz.py Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 9. mage Invoking Python's Debugger $ python -m pdb fizzbuzz.py > /Users/cbc/pycarolinas/fizzbuzz.py(7)<module>() -> """ (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 10. mage Invoking Python's Debugger $ python -m pdb fizzbuzz.py > /Users/cbc/pycarolinas/fizzbuzz.py(7)<module>() -> """ (Pdb) Full path to script being debugged Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 11. mage Invoking Python's Debugger $ python -m pdb fizzbuzz.py > /Users/cbc/pycarolinas/fizzbuzz.py(7)<module>() -> """ (Pdb) Line number of next statement to execute Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 12. mage Invoking Python's Debugger $ python -m pdb fizzbuzz.py > /Users/cbc/pycarolinas/fizzbuzz.py(7)<module>() -> """ (Pdb) Type of object last evaluated Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 13. mage Invoking Python's Debugger $ python -m pdb fizzbuzz.py > /Users/cbc/pycarolinas/fizzbuzz.py(7)<module>() -> """ (Pdb) Instruction pointer to next statement to execute Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 14. mage Invoking Python's Debugger $ python -m pdb fizzbuzz.py > /Users/cbc/pycarolinas/fizzbuzz.py(7)<module>() -> """ (Pdb) Debugger prompt Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 15. mage Python's Debugger Prompt (Pdb) help Documented commands (type help <topic>): ======================================== EOF cl disable interact next return u where a clear display j p retval unalias alias commands down jump pp run undisplay args condition enable l print rv unt b cont exit list q s until break continue h ll quit source up bt d help longlist r step w c debug ignore n restart tbreak whatis Miscellaneous help topics: ========================== exec pdb (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 16. mage Python's Debugger Prompt (Pdb) help list l(ist) [first [,last] | .] List source code for the current file. Without arguments, list 11 lines around the current line or continue the previous listing. With . as argument, list 11 lines around the current line. With one argument, list 11 lines starting at that line. With two arguments, list the given range; if the second argument is less than the first, it is a count. The current line in the current frame is indicated by "->". If an exception is being debugged, the line where the exception was originally raised or propagated is indicated by ">>", if it differs from the current line. (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 17. mage Python's Debugger Prompt (Pdb) h l l(ist) [first [,last] | .] List source code for the current file. Without arguments, list 11 lines around the current line or continue the previous listing. With . as argument, list 11 lines around the current line. With one argument, list 11 lines starting at that line. With two arguments, list the given range; if the second argument is less than the first, it is a count. The current line in the current frame is indicated by "->". If an exception is being debugged, the line where the exception was originally raised or propagated is indicated by ">>", if it differs from the current line. (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 18. mage Python's Debugger Prompt (Pdb) l 2 Generate the first n Fizz Buzz answers. 3 4 Usage: 5 6 > python fizzbuzz.py n 7 -> """ 8 9 import sys 10 11 def fizzbuzz(n): 12 """ (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 19. mage Python's Debugger Prompt (Pdb) l 6 1 """ 2 Generate the first n Fizz Buzz answers. 3 4 Usage: 5 6 > python fizzbuzz.py n 7 -> """ 8 9 import sys 10 11 def fizzbuzz(n): (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 20. mage Python's Debugger Prompt (Pdb) l . 2 Generate the first n Fizz Buzz answers. 3 4 Usage: 5 6 > python fizzbuzz.py n 7 -> """ 8 9 import sys 10 11 def fizzbuzz(n): 12 """ (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 21. mage Python's Debugger Prompt (Pdb) 3 ** (1 / 2) 1.7320508075688772 (Pdb) dir() ['__builtins__', '__file__', '__name__'] (Pdb) print(__name__) '__main__' (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 22. mage Python's Debugger Prompt (Pdb) !list <class 'list'> (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 23. mage What Is Debugging • Execute program one statement at a time • Inspect the state of objects bound to identifiers • Lather, rinse, repeat Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 24. mage Single Stepping (Pdb) s > /Users/cbc/pycarolinas/fizzbuzz.py(9)<module>() -> import sys (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 25. mage Single Stepping (Pdb) l 4 Usage: 5 6 > python fizzbuzz.py n 7 """ 8 9 -> import sys 10 11 def fizzbuzz(n): 12 """ 13 fizzbuzz(n) -> [first n Fizz Buzz answers] 14 """ (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 26. mage Single Stepping (Pdb) dir() ['__builtins__', '__doc__', '__file__', '__name__'] (Pdb) !print(__doc__) Generate the first n Fizz Buzz answers. Usage: > python fizzbuzz.py n (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 27. mage Single Stepping (Pdb) s > /Users/cbc/pycarolinas/fizzbuzz.py(11)<module>() -> def fizzbuzz(n): (Pdb) dir() ['__builtins__', '__doc__', '__file__', '__name__', 'sys'] (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 28. mage Single Stepping (Pdb) l 6 > python fizzbuzz.py n 7 """ 8 9 import sys 10 11 -> def fizzbuzz(n): 12 """ 13 fizzbuzz(n) -> [first n Fizz Buzz answers] 14 """ 15 16 answers = [] (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 29. mage Single Stepping (Pdb) l 17 for x in range(1,n+1): 18 answer = "" 19 if not x%3: 20 answer += "Fizz" 21 if not x%5: 22 answer += "Buzz" 23 if not answer: 24 answer = x 25 answers.append(answer) 26 return answers 27 (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 30. mage Single Stepping (Pdb) l . 6 > python fizzbuzz.py n 7 """ 8 9 import sys 10 11 -> def fizzbuzz(n): 12 """ 13 fizzbuzz(n) -> [first n Fizz Buzz answers] 14 """ 15 16 answers = [] (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 31. mage Single Stepping (Pdb) s > /Users/cbc/pycarolinas/fizzbuzz.py(28)<module>() -> if __name__ == '__main__': (Pdb) dir() ['__builtins__', '__doc__', '__file__', '__name__', 'fizzbuzz', 'sys'] (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 32. mage Single Stepping (Pdb) l 23 if not answer: 24 answer = x 25 answers.append(answer) 26 return answers 27 28 -> if __name__ == '__main__': 29 try: 30 if len(sys.argv) != 2: 31 raise ValueError("Incorrect number of arguments") 32 answers = fizzbuzz(int(sys.argv[1])) 33 print(" ".join([str(answer) for answer in answers])) (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 33. mage Single Stepping (Pdb) s > /Users/cbc/pycarolinas/fizzbuzz.py(29)<module>() -> try: (Pdb) s > /Users/cbc/pycarolinas/fizzbuzz.py(30)<module>() -> if len(sys.argv) != 2: (Pdb) s > /Users/cbc/pycarolinas/fizzbuzz.py(31)<module>() -> raise ValueError("Incorrect number of arguments") (Pdb) s ValueError: Incorrect number of arguments > /Users/cbc/pycarolinas/fizzbuzz.py(31)<module>() -> raise ValueError("Incorrect number of arguments") (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 34. mage Single Stepping (Pdb) s > /Users/cbc/pycarolinas/fizzbuzz.py(34)<module>() -> except: (Pdb) s > /Users/cbc/pycarolinas/fizzbuzz.py(35)<module>() -> print(__doc__) (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 35. mage Single Stepping (Pdb) s Generate the first n Fizz Buzz answers. Usage: > python fizzbuzz.py n --Return-- > /Users/cbc/pycarolinas/fizzbuzz.py(35)<module>()->None -> print(__doc__) (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 36. mage Single Stepping (Pdb) s --Return-- > <string>(1)<module>()->None (Pdb) l [EOF] (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 37. mage Single Stepping (Pdb) s > /opt/python330/lib/python3.3/bdb.py(409)run() -> self.quitting = True (Pdb) s The program finished and will be restarted > /Users/cbc/pycarolinas/fizzbuzz.py(7)<module>() -> """ (Pdb) dir() ['__builtins__', '__file__', '__name__'] (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 38. mage Single Stepping (Pdb) q $ Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 39. mage Invoking Python's Debugger $ python -m pdb fizzbuzz.py 100 Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 40. mage Invoking Python's Debugger $ python -m pdb fizzbuzz.py 100 > /Users/cbc/pycarolinas/fizzbuzz.py(7)<module>() -> """ (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 41. mage Python's Debugger Prompt (Pdb) l 2 Generate the first n Fizz Buzz answers. 3 4 Usage: 5 6 > python fizzbuzz.py n 7 -> """ 8 9 import sys 10 11 def fizzbuzz(n): 12 """ (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 42. mage Python's Debugger Prompt (Pdb) l 13 fizzbuzz(n) -> [first n Fizz Buzz answers] 14 """ 15 16 answers = [] 17 for x in range(1,n+1): 18 answer = "" 19 if not x%3: 20 answer += "Fizz" 21 if not x%5: 22 answer += "Buzz" 23 if not answer: (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 43. mage Python's Debugger Prompt (Pdb) l 24 answer = x 25 answers.append(answer) 26 return answers 27 28 if __name__ == '__main__': 29 try: 30 if len(sys.argv) != 2: 31 raise ValueError("Incorrect number of arguments") 32 answers = fizzbuzz(int(sys.argv[1])) 33 print(" ".join([str(answer) for answer in answers])) 34 except: (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 44. mage Setting a Breakpoint (Pdb) b 30 Breakpoint 1 at /Users/cbc/pycarolinas/fizzbuzz.py:30 (Pdb) l 30 25 answers.append(answer) 26 return answers 27 28 if __name__ == '__main__': 29 try: 30 B if len(sys.argv) != 2: 31 raise ValueError("Incorrect number of arguments") 32 answers = fizzbuzz(int(sys.argv[1])) 33 print(" ".join([str(answer) for answer in answers])) 34 except: 35 print(__doc__) (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 45. mage Setting a Breakpoint (Pdb) l . 2 Generate the first n Fizz Buzz answers. 3 4 Usage: 5 6 > python fizzbuzz.py n 7 -> """ 8 9 import sys 10 11 def fizzbuzz(n): 12 """ (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 46. mage Setting a Breakpoint (Pdb) c > /Users/cbc/pycarolinas/fizzbuzz.py(30)<module>() -> if len(sys.argv) != 2: (Pdb) l 25 answers.append(answer) 26 return answers 27 28 if __name__ == '__main__': 29 try: 30 B-> if len(sys.argv) != 2: 31 raise ValueError("Incorrect number of arguments") 32 answers = fizzbuzz(int(sys.argv[1])) 33 print(" ".join([str(answer) for answer in answers])) 34 except: 35 print(__doc__) (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 47. mage Stepping Into a Function (Pdb) len(sys.argv) 2 (Pdb) s > /Users/cbc/pycarolinas/fizzbuzz.py(32)<module>() -> answers = fizzbuzz(int(sys.argv[1])) (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 48. mage Stepping Into a Function (Pdb) s --Call-- > /Users/cbc/pycarolinas/fizzbuzz.py(11)fizzbuzz() -> def fizzbuzz(n): (Pdb) l 6 > python fizzbuzz.py n 7 """ 8 9 import sys 10 11 -> def fizzbuzz(n): 12 """ 13 fizzbuzz(n) -> [first n Fizz Buzz answers] 14 """ 15 16 answers = [] (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 49. mage Stepping Into a Function (Pdb) p n 100 (Pdb) s > /Users/cbc/pycarolinas/fizzbuzz.py(16)fizzbuzz() -> answers = [] (Pdb) s > /Users/cbc/pycarolinas/fizzbuzz.py(17)fizzbuzz() -> for x in range(1,n+1): (Pdb) s > /Users/cbc/pycarolinas/fizzbuzz.py(18)fizzbuzz() -> answer = "" (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 50. mage Stepping Into a Function (Pdb) l 13 fizzbuzz(n) -> [first n Fizz Buzz answers] 14 """ 15 16 answers = [] 17 for x in range(1,n+1): 18 -> answer = "" 19 if not x%3: 20 answer += "Fizz" 21 if not x%5: 22 answer += "Buzz" 23 if not answer: (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 51. mage Stepping Into a Function (Pdb) dir() ['answers', 'n', 'x'] (Pdb) where /opt/python330/lib/python3.3/bdb.py(405)run() -> exec(cmd, globals, locals) <string>(1)<module>() /Users/cbc/pycarolinas/fizzbuzz.py(32)<module>() -> answers = fizzbuzz(int(sys.argv[1])) > /Users/cbc/pycarolinas/fizzbuzz.py(18)fizzbuzz() -> answer = "" (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 52. mage Stack Frames (Pdb) up > /Users/cbc/pycarolinas/fizzbuzz.py(32)<module>() -> answers = fizzbuzz(int(sys.argv[1])) (Pdb) dir() ['__builtins__', '__doc__', '__file__', '__name__', 'fizzbuzz', 'sys'] (Pdb) down > /Users/cbc/pycarolinas/fizzbuzz.py(18)fizzbuzz() -> answer = "" (Pdb) down *** Newest frame (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 53. mage Stepping Into a Function (Pdb) l 13 fizzbuzz(n) -> [first n Fizz Buzz answers] 14 """ 15 16 answers = [] 17 for x in range(1,n+1): 18 -> answer = "" 19 if not x%3: 20 answer += "Fizz" 21 if not x%5: 22 answer += "Buzz" 23 if not answer: (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 54. mage Stepping Into a Function (Pdb) c 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17 Fizz 19 Buzz Fizz 22 23 Fizz Buzz 26 Fizz 28 29 FizzBuzz 31 32 Fizz 34 Buzz Fizz 37 38 Fizz Buzz 41 Fizz 43 44 FizzBuzz 46 47 Fizz 49 Buzz Fizz 52 53 Fizz Buzz 56 Fizz 58 59 FizzBuzz 61 62 Fizz 64 Buzz Fizz 67 68 Fizz Buzz 71 Fizz 73 74 FizzBuzz 76 77 Fizz 79 Buzz Fizz 82 83 Fizz Buzz 86 Fizz 88 89 FizzBuzz 91 92 Fizz 94 Buzz Fizz 97 98 Fizz Buzz The program finished and will be restarted > /Users/cbc/pycarolinas/fizzbuzz.py(7)<module>() -> """ (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 55. mage Listing Breakpoints (Pdb) b Num Type Disp Enb Where 1 breakpoint keep yes at /Users/cbc/pycarolinas/fizzbuzz.py:30 breakpoint already hit 1 time (Pdb) c > /Users/cbc/pycarolinas/fizzbuzz.py(30)<module>() -> if len(sys.argv) != 2: (Pdb) s > /Users/cbc/pycarolinas/fizzbuzz.py(32)<module>() -> answers = fizzbuzz(int(sys.argv[1])) (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 56. mage Stepping Over a Function (Pdb) n > /Users/cbc/pycarolinas/fizzbuzz.py(33)<module>() -> print(" ".join([str(answer) for answer in answers])) (Pdb) pp answers [1, 2, 'Fizz', ... 98, 'Fizz', 'Buzz'] (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 57. mage Stepping Over a Function (Pdb) c 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17 Fizz 19 Buzz Fizz 22 23 Fizz Buzz 26 Fizz 28 29 FizzBuzz 31 32 Fizz 34 Buzz Fizz 37 38 Fizz Buzz 41 Fizz 43 44 FizzBuzz 46 47 Fizz 49 Buzz Fizz 52 53 Fizz Buzz 56 Fizz 58 59 FizzBuzz 61 62 Fizz 64 Buzz Fizz 67 68 Fizz Buzz 71 Fizz 73 74 FizzBuzz 76 77 Fizz 79 Buzz Fizz 82 83 Fizz Buzz 86 Fizz 88 89 FizzBuzz 91 92 Fizz 94 Buzz Fizz 97 98 Fizz Buzz The program finished and will be restarted > /Users/cbc/pycarolinas/fizzbuzz.py(7)<module>() -> """ (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 58. mage Stepping Over a Function (Pdb) c > /Users/cbc/pycarolinas/fizzbuzz.py(30)<module>() -> if len(sys.argv) != 2: (Pdb) b Num Type Disp Enb Where 1 breakpoint keep yes at /Users/cbc/pycarolinas/fizzbuzz.py:30 breakpoint already hit 3 times (Pdb) s > /Users/cbc/pycarolinas/fizzbuzz.py(32)<module>() -> answers = fizzbuzz(int(sys.argv[1])) (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 59. mage Stepping Over a Function (Pdb) s --Call-- > /Users/cbc/pycarolinas/fizzbuzz.py(11)fizzbuzz() -> def fizzbuzz(n): (Pdb) s > /Users/cbc/pycarolinas/fizzbuzz.py(16)fizzbuzz() -> answers = [] (Pdb) s > /Users/cbc/pycarolinas/fizzbuzz.py(17)fizzbuzz() -> for x in range(1,n+1): (Pdb) s > /Users/cbc/pycarolinas/fizzbuzz.py(18)fizzbuzz() -> answer = "" (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 60. mage Stepping Over a Function (Pdb) r --Return-- > /Users/cbc/pycarolinas/fizzbuzz.py(26)fizzbuzz()-> [1, 2, 'Fizz', 4, 'Buzz', 'Fizz', ...] -> return answers (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 61. mage Stepping Over a List Comprehension (Pdb) s > /Users/cbc/pycarolinas/fizzbuzz.py(33)<module>() -> print(" ".join([str(answer) for answer in answers])) (Pdb) s --Call-- > /Users/cbc/pycarolinas/fizzbuzz.py(33)<listcomp>() -> print(" ".join([str(answer) for answer in answers])) (Pdb) s > /Users/cbc/pycarolinas/fizzbuzz.py(33)<listcomp>() -> print(" ".join([str(answer) for answer in answers])) (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 62. mage Stepping Over a List Comprehension (Pdb) r --Return-- > /Users/cbc/pycarolinas/fizzbuzz.py(33)<listcomp>()-> ['1', '2', 'Fizz', '4', 'Buzz', 'Fizz', ...] -> print(" ".join([str(answer) for answer in answers])) (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 63. mage Clear Breakpoints (Pdb) h clear cl(ear) filename:lineno cl(ear) [bpnumber [bpnumber...]] With a space separated list of breakpoint numbers, clear those breakpoints. Without argument, clear all breaks (but first ask confirmation). With a filename:lineno argument, clear all breaks at that line in that file. (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 64. mage Disable Breakpoints (Pdb) h disable disable bpnumber [bpnumber ...] Disables the breakpoints given as a space separated list of breakpoint numbers. Disabling a breakpoint means it cannot cause the program to stop execution, but unlike clearing a breakpoint, it remains in the list of breakpoints and can be (re-)enabled. (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 65. mage Enable Breakpoints (Pdb) h enable enable bpnumber [bpnumber ...] Enables the breakpoints given as a space separated list of breakpoint numbers. (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 66. mage Monitor Objects for Changes (Pdb) h display display [expression] Display the value of the expression if it changed, each time execution stops in the current frame. Without expression, list all display expressions for the current frame. (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 67. mage Conditional Breakpoints (Pdb) h condition condition bpnumber [condition] Set a new condition for the breakpoint, an expression which must evaluate to true before the breakpoint is honored. If condition is absent, any existing condition is removed; i.e., the breakpoint is made unconditional. (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 68. mage Skip Over Breakpoints (Pdb) h ignore ignore bpnumber [count] Set the ignore count for the given breakpoint number. If count is omitted, the ignore count is set to 0. A breakpoint becomes active when the ignore count is zero. When non-zero, the count is decremented each time the breakpoint is reached and the breakpoint is not disabled and any associated condition evaluates to true. (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 69. mage Debugger Macros (Pdb) help alias alias [name [command [parameter parameter ...] ]] Create an alias called 'name' that executes 'command'. The command must *not* be enclosed in quotes. Replaceable parameters can be indicated by %1, %2, and so on, while %* is replaced by all the parameters. If no command is given, the current alias for name is shown. If no name is given, all aliases are listed. Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 70. mage One Time Breakpoints (Pdb) h tbreak tbreak [ ([filename:]lineno | function) [, condition] ] Same arguments as break, but sets a temporary breakpoint: it is automatically deleted when first hit. (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 71. mage What Is Debugging • Execute entire program one step at the time • Execute only suspect portions of program • Isolate suspect portions of program Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 72. mage Setting a Trace if __name__ == '__main__': try: if len(sys.argv) != 2: import pdb; pdb.set_trace() raise ValueError("Incorrect number of arguments") answers = fizzbuzz(int(sys.argv[1])) print(" ".join([str(answer) for answer in answers])) except: print(__doc__) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 73. mage Setting a Trace $ python fizzbuzzNG.py > /Users/cbc/pycarolinas/fizzbuzzNG.py(32)<module>() -> raise ValueError("Incorrect number of arguments") (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 74. mage Post-mortem Debugging if __name__ == '__main__': if len(sys.argv) != 2: raise ValueError("Incorrect number of arguments") answers = fizzbuzz(int(sys.argv[1])) print(" ".join([str(answer) for answer in answers])) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 75. mage Post-mortem Debugging $ python -i fizzbuzzNG2.py Traceback (most recent call last): File "fizzbuzzNG2.py", line 30, in <module> raise ValueError("Incorrect number of arguments") ValueError: Incorrect number of arguments >>> Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 76. mage Post-mortem Debugging >>> import pdb; pdb.pm() > /Users/cbc/pycarolinas/fizzbuzzNG2.py(30)<module>() -> raise ValueError("Incorrect number of arguments") (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 77. mage Debugger Runner >>> import fizzbuzz >>> import pdb >>> pdb.run('fizzbuzz.fizzbuzz(100)') > <string>(1)<module>() (Pdb) s --Call-- > /Users/cbc/pycarolinas/fizzbuzz.py(11)fizzbuzz() -> def fizzbuzz(n): (Pdb) Programming PyCamp™ Copyright © 2012 Trizpug For The People
  • 78. mage Python DEBUGGING Fundamentals Questions? cbc@chriscalloway.org http://drunkenpython.org/pycarolinas.zip http://docs.python.org/py3k/library/pdb.html#module-pdb Programming PyCamp™ Copyright © 2012 Trizpug For The People