Source

filesnake / fabfile.py

import os
import re

patterns = ["pyc$","#$",]
def _filter(list,regex):
    reg = re.compile(regex)
    return filter(reg.search, list)

def clean():
    
    for root, dirname, files in os.walk("."):
        filtered = []
        for p in patterns:
            filtered += _filter(files,p)
        for f in filtered:
            print "Removing",f
            os.remove(os.path.join(root,f))