Skip to content

Instantly share code, notes, and snippets.

View pybites's full-sized avatar

Pybites pybites

View GitHub Profile
import os
filename = 'homework.txt'
if not os.path.exists(filename):
with open(filename, 'w'): pass
answer1 = """1).
X | 3 | X
____|____|____
>>> from datetime import datetime
>>> def today(dt=datetime.now()):
... print(dt)
...
>>> today()
2020-12-12 22:18:26.432268
# oops
>>> today()
2020-12-12 22:18:26.432268
>>> today()
#!/usr/bin/env python3.9
import argparse
import importlib
import inspect
import pydoc
def get_callable(arg):
module_str, name = arg.rsplit(".", 1)
module = importlib.import_module(module_str)
# from Fluent Python 2nd ed
class Averager():
def __init__(self):
self.series = []
def __call__(self, new_value):
self.series.append(new_value)
total = sum(self.series)
# cars.py
from datetime import date
class Car:
def __init__(self, model, year):
self.model = model
self.year = year
self._mileage = []
import concurrent.futures
import os
import re
from timeit import timeit
import requests
from tqdm import tqdm
URLS = 'urls'
import concurrent.futures
import os
import re
from timeit import timeit
import requests
URLS = 'urls'
@pybites
pybites / amzlink.py
Last active December 17, 2020 15:21
import os
# make venv and pip install selenium
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
# set your codechalleng.es username and password in venv/bin/activate, then source it
user = os.getenv('PB_USER')
password = os.getenv('PB_PW')
{"achievementPoints": 14565,
"battlegroup": "Cyclone",
"calcClass": "V",
"class": 9,
"faction": 0,
"gender": 0,
"lastModified": 1519011260000,
"level": 110,
"mounts": {"collected": [{"creatureId": 32158,
"icon": "ability_mount_drake_blue",