def dire(o, pat=None):
    """like dir, but can filter results with re pat"""

    names = dir(o)
    if not pat:
        return names

    import re
    pat = re.compile(pat)
    def match(name, fn=pat.search):
       return fn(name) is not None
    return filter(match, names)
like dir, but can filter results with re pat
recipes/Python/576389_filtered_interpolation/recipe-576389.py