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 wraps | |
| import time | |
| def memoize(lookup): | |
| cache = {} | |
| @wraps(lookup) | |
| def wrapper(key): | |
| if key in cache: | |
| print "from cache" | |
| return cache[key] |
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
| 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) |