|
| 1 | +pickle.dump(my_dogs, open("dogs.txt", "wb")) |
| 2 | + |
| 3 | +######################### |
| 4 | + |
| 5 | + ('Bold Ruler', |
| 6 | + 'Somethingroyal', 'Secretariat') |
| 7 | + |
| 8 | + horses = collections.namedtuple("horses", ("sire", "dam", "foal")) |
| 9 | + |
| 10 | + ways = [‘WAYS-AII’, ‘WAYS_AII’, ‘WAYS_SI’, ‘WAYS-CE’, ‘WAYS-AQR’, ‘WAYS-CE’, ‘WAYS-SMA’, ‘WAYS-CE’, ‘WAYS-FR’, ‘WAYS-ER’] |
| 11 | + |
| 12 | +d = collections.defaultdict(list) |
| 13 | +############################# |
| 14 | + |
| 15 | +def foo(a, b, c=1): |
| 16 | + '''cool math''' |
| 17 | + return (a+b) * c |
| 18 | + |
| 19 | +######################## |
| 20 | + |
| 21 | + def print_args(func): |
| 22 | + def mod(*args, **kwargs): |
| 23 | + '''print the args''' |
| 24 | + print("Arguments: ", args, kwargs) |
| 25 | + return func(*args, **kwargs) |
| 26 | + return mod |
| 27 | + |
| 28 | +########################## |
| 29 | + |
| 30 | +@print_args |
| 31 | +def foo(a, b, c=1): |
| 32 | + '''cool math''' |
| 33 | + return (a+b) * c |
| 34 | + |
| 35 | +########################## |
| 36 | + |
| 37 | +def print_args(func): |
| 38 | + @functools.wraps(func) |
| 39 | + def mod(*args, **kwargs): |
| 40 | + '''print the args''' |
| 41 | + print("Arguments: ", args, kwargs) |
| 42 | + return func(*args, **kwargs) |
| 43 | + return mod |
| 44 | + |
| 45 | +########################## |
| 46 | + |
| 47 | +def sleepy_thread(i): |
| 48 | + print(f"Thread {i} is going to sleep") |
| 49 | + time.sleep(5) |
| 50 | + print(f"Thread {i} is back!!") |
| 51 | + |
| 52 | + |
| 53 | + t = Thread(target=sleepy_thread, args=(i,)) |
| 54 | + |
| 55 | +############################################## |
| 56 | + |
| 57 | +def find_numbers(text): |
| 58 | + print( re.findall("\(\d{3}\)[- ]\d{3}-\d{4}", text)) |
| 59 | + |
0 commit comments