Created
December 7, 2011 14:04
-
-
Save dreispt/1442918 to your computer and use it in GitHub Desktop.
Python example of pdb usage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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