This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cache = None | |
def get_file(): | |
if cache is None: | |
cache = load_file_from_url() | |
return cache |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import lru_cache | |
@lru_cache | |
def get_file(): | |
return load_file_from_url() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
passwords = {} | |
for password in password_list: | |
if password in passwords.keys(): | |
passwords[password] = 0 | |
else: | |
passwords[password] += 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |