Skip to content

Instantly share code, notes, and snippets.

@dreispt
Created December 7, 2011 14:04
Show Gist options
  • Save dreispt/1442918 to your computer and use it in GitHub Desktop.
Save dreispt/1442918 to your computer and use it in GitHub Desktop.
Python example of pdb usage
"""
PDB example.
At (pdb) prompt use:
(n)ext +repeat ENTER,
(p)rint var
(l)ist program,
(c)ontinue
(q)quit,
(s)tep into subroutines, use instead of "n"
(r)eturn, continue until setp out of subroutine
"""
import pdb
def divisors(n):
res = []
for i in xrange(2, n-1):
modulo = n%i
if modulo == 0:
res.append(i)
return res
pdb.set_trace()
a = 10
z = 13
primes = 0
print "#", "Prime?", "Divisors"
for n in xrange(a,z+1):
dv = divisors(n)
print n, dv ==[], dv
if dv == []:
primes += 1
print primes, "prime numbers found"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment