This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Copy all matches to a vim search and paste in new buffer separated by lines | |
"Source this file to try it out. | |
"Let's say you have a python file and want to find all the methods/properties | |
"on self mentioned in a file (commence esoteric example): | |
"class Student(object): | |
" def __init__(self, name): | |
" self.name = name | |
" def set_gpa(self, gpa): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
#ugly one-liner | |
def _ugly_split_at(pred, seq): | |
return list(itertools.ifilter( | |
None, | |
[ | |
( | |
(seq[idx:idx+1] + list(itertools.takewhile(lambda x: not pred(x), seq[idx+1:]))) | |
if idx == 0 or pred(el) | |
else [] |
NewerOlder