pudb/debug_me.py

61 lines
1.0 KiB
Python
Raw Normal View History

from collections import namedtuple
2021-03-15 16:50:54 -05:00
Color = namedtuple('Color', ['red', 'green', 'blue', 'alpha'])
class MyClass(object):
def __init__(self, a, b):
self.a = a
self.b = b
self._b = [b]
mc = MyClass(15, MyClass(12, None))
from pudb import set_trace; set_trace()
2009-06-08 23:37:13 -04:00
def simple_func(x):
x += 1
s = range(20)
z = None
w = ()
y = dict((i, i**2) for i in s)
k = set(range(5, 99))
2021-03-15 16:50:54 -05:00
c = Color(137, 214, 56, 88)
try:
x.invalid
except AttributeError:
pass
#import sys
#sys.exit(1)
2009-06-08 23:37:13 -04:00
return 2*x
2009-06-08 14:50:27 -04:00
def fermat(n):
"""Returns triplets of the form x^n + y^n = z^n.
Warning! Untested with n > 2.
"""
2012-05-12 02:37:28 -04:00
# source: "Fermat's last Python script"
# https://earthboundkid.jottit.com/fermat.py
# :)
2009-07-25 14:56:29 -07:00
for x in range(100):
2009-06-08 14:50:27 -04:00
for y in range(1, x+1):
for z in range(1, x**n+y**n + 1):
if x**n + y**n == z**n:
yield x, y, z
2012-07-13 17:44:44 -07:00
print("SF %s" % simple_func(10))
2009-06-08 23:37:13 -04:00
2009-06-08 14:50:27 -04:00
for i in fermat(2):
2012-07-13 17:44:44 -07:00
print(i)
2009-06-08 14:50:27 -04:00
2012-07-13 17:44:44 -07:00
print("FINISHED")