Skip to content

Instantly share code, notes, and snippets.

View metaperl's full-sized avatar

Structure and Interpretation of Computer Programs metaperl

View GitHub Profile
View exception_handler.py
class _ExceptionHandlerBase:
def __init__(self, handler_map):
self._handler_map = handler_map
def __call__(self, func):
def wrapper(*args, **kwargs):
with self:
func(*args, **kwargs)
return wrapper
@hrldcpr
hrldcpr / tree.md
Last active December 5, 2023 09:57
one-line tree in python
View tree.md

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!