Skip to content

Instantly share code, notes, and snippets.

@CH-DanReif
CH-DanReif / wtaf.py
Last active March 6, 2019 01:23
WTAF: Try to grok an arbitrary Python object, as well as one reasonably can. N.b. it tries to call the methods. You own anything you break.
import types
from typing import Callable, Dict
def _funcify(obj: object, key: str, hist: Dict) -> str:
"""
Call {obj}.{key}() if possible.
@param hist: A dict that starts empty when we begin enumerating an object.
If this method would otherwise recurse, even in a loop, don't.