Skip to content

Instantly share code, notes, and snippets.

@sparkydogX
Created March 6, 2019 02:42
Show Gist options
  • Save sparkydogX/39021fbb7b77de540fd75af23eae3739 to your computer and use it in GitHub Desktop.
Save sparkydogX/39021fbb7b77de540fd75af23eae3739 to your computer and use it in GitHub Desktop.
This is a simple example for python filter
def evenFilter(d):
if d['idx'] % 2 == 0:
return True
else:
return False
if __name__ == '__main__':
L = []
for i in range(10):
d={}
d['idx'] = i
L.append(d)
print(L)
fL = list(filter(evenFilter,L))
print(fL)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment