I am trying to chain filter functions together so I created these 2 functions.
def AndChain(*filters): return (lambda asset: reduce((lambda r, f: apply(f, asset) and r), filters)) def OrChain(*filters): return (lambda asset: reduce((lambda r, f: apply(f, asset) or r), filters)) Where filters are simply functions that take a single argument and return true or false. My intention is to use these functions like this: f = AndChain(AssetTypeFilter(), CurrencyFilter()) filteredCol = filter(f, col) I am receiving the following error (where Asset is the type of items in my collection) Traceback (most recent call last): File , line 0, in <stdin>##44 File c:\proj\ofts\com.oakwoodft.ofts.compliance\complianceframework\filters\assetfilters.py, line 5, in <lambda File c:\proj\ofts\com.oakwoodft.ofts.compliance\complianceframework\filters\assetfilters.py, line 5, in <lambda TypeError: <Asset object at 0x000000000000002B> is not enumerable Am I going about this totally wrong? Is there a better solution? Thanks. Drew Schaeffer
-- http://mail.python.org/mailman/listinfo/python-list