2021-03-07 00:52:47 +03:00
from collections import namedtuple
2024-07-11 17:36:48 +03:00
Color = namedtuple ( " Color " , [ " red " , " green " , " blue " , " alpha " ] )
2021-03-07 00:52:47 +03:00
2015-05-25 21:13:48 +03:00
class MyClass ( object ) :
def __init__ ( self , a , b ) :
self . a = a
self . b = b
self . _b = [ b ]
2024-07-11 17:36:48 +03:00
2015-05-25 21:13:48 +03:00
mc = MyClass ( 15 , MyClass ( 12 , None ) )
2009-09-11 17:50:00 +04:00
2015-09-15 12:16:15 +03:00
2024-07-11 17:36:48 +03:00
from pudb import set_trace
set_trace ( )
2019-01-23 18:30:11 +03:00
2009-06-09 07:37:13 +04:00
def simple_func ( x ) :
x + = 1
2009-06-10 16:10:29 +04:00
s = range ( 20 )
2024-07-11 17:36:48 +03:00
z = None # noqa: F841
w = ( ) # noqa: F841
2009-06-10 16:10:29 +04:00
2024-07-11 17:36:48 +03:00
y = { i : i * * 2 for i in s } # noqa: F841
2009-06-10 16:10:29 +04:00
2024-07-11 17:36:48 +03:00
k = set ( range ( 5 , 99 ) ) # noqa: F841
c = Color ( 137 , 214 , 56 , 88 ) # noqa: F841
2009-06-10 16:10:29 +04:00
try :
2024-07-11 17:36:48 +03:00
x . invalid # noqa: B018
2009-06-10 16:10:29 +04:00
except AttributeError :
pass
2024-07-11 17:36:48 +03:00
# import sys
# sys.exit(1)
2009-06-10 16:10:29 +04:00
2009-06-09 07:37:13 +04:00
return 2 * x
2015-09-15 12:16:15 +03:00
2009-06-08 22: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 10:37:28 +04:00
# source: "Fermat's last Python script"
# https://earthboundkid.jottit.com/fermat.py
# :)
2009-07-26 01:56:29 +04:00
for x in range ( 100 ) :
2009-06-08 22: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
2024-07-11 17:36:48 +03:00
2012-07-14 04:44:44 +04:00
print ( " SF %s " % simple_func ( 10 ) )
2009-06-09 07:37:13 +04:00
2009-06-08 22:50:27 +04:00
for i in fermat ( 2 ) :
2012-07-14 04:44:44 +04:00
print ( i )
2009-06-08 22:50:27 +04:00
2012-07-14 04:44:44 +04:00
print ( " FINISHED " )