Skip to content

Instantly share code, notes, and snippets.

@HassankSalim
Created August 28, 2018 04:42
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 HassankSalim/a3e0f27d3e140f48bdf0c820714f7c03 to your computer and use it in GitHub Desktop.
Save HassankSalim/a3e0f27d3e140f48bdf0c820714f7c03 to your computer and use it in GitHub Desktop.
import re
# Custom grep
grep = lambda lib, regex : filter(lambda x : re.search(regex, x), dir(lib))
# Usage
# input: list(grep(bson, 'deco'))
# result: ['_utf_8_decode', 'decode_all', 'decode_file_iter', 'decode_iter']
# input: list(grep(numpy, '^a.*y$'))
# result: ['any', 'array', 'asanyarray', 'asarray', 'ascontiguousarray', 'asfarray', 'asfortranarray']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment