Clean up find command, move code to utils.

This commit is contained in:
Todd Gamblin
2014-04-14 12:53:23 -07:00
parent 1e51daab08
commit 1f9dfeb9b5
5 changed files with 99 additions and 58 deletions

View File

@@ -31,6 +31,22 @@
# Ignore emacs backups when listing modules
ignore_modules = [r'^\.#', '~$']
def partition_list(elements, predicate):
"""Partition a list into two lists, the first containing elements
for which the predicate evaluates to true, the second containing
those for which it is false.
"""
trues = []
falses = []
for elt in elements:
if predicate(elt):
trues.append(elt)
else:
falses.append(elt)
return trues, falses
def caller_locals():
"""This will return the locals of the *parent* of the caller.
This allows a fucntion to insert variables into its caller's