Skip to content

Instantly share code, notes, and snippets.

@felipecruz
Last active November 9, 2015 18:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felipecruz/1c40098eb62408aaaf67 to your computer and use it in GitHub Desktop.
Save felipecruz/1c40098eb62408aaaf67 to your computer and use it in GitHub Desktop.
>>> data = ['aa', 'bb', 'ab', 'bc']
>>> def _filter_native(data):
... sts = ['a', 'b']
... rets = []
... for st in sts:
... rets.append((st, filter(lambda x: x.startswith(st), data)))
... return rets
...
>>> rdds = _filter_native(data)
>>> for st, rdd in rdds:
... print((st, list(rdd)))
...
('a', ['aa', 'ab'])
('b', ['bb', 'bc'])
>>> import sys; print(sys.version)
2.7.10 (default, Aug 22 2015, 20:33:39)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.1)]
>>> data = ['aa', 'bb', 'ab', 'bc']
>>> def _filter_native(data):
... sts = ['a', 'b']
... rets = []
... for st in sts:
... rets.append((st, filter(lambda x: x.startswith(st), data)))
... return rets
...
>>> rdds = _filter_native(data)
>>> for st, rdd in rdds:
... print((st, list(rdd)))
...
('a', ['bb', 'bc'])
('b', ['bb', 'bc'])
>>> import sys; print(sys.version)
3.5.0 (default, Sep 20 2015, 15:59:58)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)]
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment