You could also use itertools:
import itertools
import re
find = re.compile("pattern")
for line in itertools.ifilter(lambda x: find.search(x),
file(filepath)):
print line
Fredrik Lundh wrote:
> bhavya sg wrote:
>
> > I saw in PEP4 of python 2.5 that grep module has gone
> > obsolete in perl
Of course you can always use grep as an external process (if the OS has
it). For example:
---
In [1]: import subprocess
In [2]: out=subprocess.Popen( 'grep -i blah ./tmp/*',
stdout=subprocess.PIPE, shell=True ).communicate()[0]
In [
bhavya sg wrote:
> I saw in PEP4 of python 2.5 that grep module has gone
> obsolete in perl 2.5. But I am not able to find an
> alternative for that.
the grep module has been deprecated for ages (it's been in the lib-old
non-standard library since at least Python 2.1). The old grep module
dep
Hi,
I saw in PEP4 of python 2.5 that grep module has gone
obsolete in perl 2.5. But I am not able to find an
alternative for that.My doubt is "are the other forms
of grep like egrep and ggrep be used instead"?
cheers,
Spurthi
__