Skip to content

Instantly share code, notes, and snippets.

@ThriceGood
ThriceGood / memoize.py
Created December 23, 2016 10:05
simple memoizer
from functools import wraps
import time
def memoize(lookup):
cache = {}
@wraps(lookup)
def wrapper(key):
if key in cache:
print "from cache"
return cache[key]
@ThriceGood
ThriceGood / logger.py
Last active February 26, 2018 15:51
Python Logging wrapper for easy logging
import logging
import os
class Logger:
def __init__(self, name):
self.create_log_dir()
self.logger = logging.getLogger('{}'.format(name))
format = "%(asctime)s [%(levelname)s]: %(message)s"
logging.basicConfig(format=format, level=logging.DEBUG)