Skip to content

Instantly share code, notes, and snippets.

class ReadInstructions:
def __init__(include: set, exclude: set, read_all: bool):
self.include = include
self.exclude = exclude
self.read_all = read_all
def __and__(self, other):
return self.__class__(
include=(self.include & other.include),
exclude=(self.exclude | other.exclude),
cache = None
def get_file():
if cache is None:
cache = load_file_from_url()
return cache
from functools import lru_cache
@lru_cache
def get_file():
return load_file_from_url()
numbers = [5, 8, 6, 3, 9, 9, 2, 4, 7, 7, 6]
def sort(arr):
bucket = [0] * 100
for number in arr:
bucket[number] += 1
sorted_arr = []
for i, num in enumerate(bucket):
passwords = {}
for password in password_list:
if password in passwords.keys():
passwords[password] = 0
else:
passwords[password] += 1
@hvuhsg
hvuhsg / dotteddict.py
Last active October 27, 2021 15:16
Use dot to access dict values
class DotedDict(dict):
def __getitem__(self, item):
value = super().__getitem__(item)
if isinstance(value, dict):
value = DotedDict(value)
return value
def __getattr__(self, item):
return self[item]