Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #87896
| Date | 2015-03-24 20:40 +0100 |
|---|---|
| From | Vincent Vande Vyvre <vincent.vande.vyvre@telenet.be> |
| Subject | Re: Regex Python Help |
| References | <099b0ca2-1f5e-4eb4-a7d0-d8210bcca51a@googlegroups.com> <43835701-a845-4a59-8936-0be236dfa59f@googlegroups.com> <5511BD4E.6010701@telenet.be> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.111.1427226044.10327.python-list@python.org> (permalink) |
Le 24/03/2015 20:38, Vincent Vande Vyvre a écrit :
> Le 24/03/2015 20:22, Gregg Dotoli a écrit :
>> Thank you! But
>>
>> The print error is gone, but now the script quickly finishes and
>> doesnt walk
>> the OS tree or search.
>>
>> Gregg
>>
>>
>>
>> On Tuesday, March 24, 2015 at 2:14:32 PM UTC-4, Gregg Dotoli wrote:
>>> I am creating a tool to search a filesystem for one simple string.
>>> I cannot get the syntax correct.
>>> Thank you in advance for your help.
>>>
>>> import sys
>>> import re
>>> import os
>>> path='/'
>>> viewfiles=os.listdir(path)
>>> for allfiles in viewfiles:
>>> file= os.path.join(path, allfiles)
>>> text=open(file, "r")
>>> for line in text:
>>> if re.match("DECRYPT_I", line):
>>> print line,
>>>
>>> ----------------------------------------------------------
>>> This should search every file for the simple regex "DECRYPT_I"
>>> This is from the root down.
>>>
>>> The error is:
>>>
>>> SyntaxError: Missing parentheses in call to 'print'
>>>
>>> Please help.
>>> Gregg Dotoli
> Your indentation is wrong.
>
> for allfiles in viewfiles:
> file= os.path.join(path, allfiles)
> text=open(file, "r")
> for line in text:
> if re.match("DECRYPT_I", line):
> print line,
>
>
> Vincent
... and me too
for allfiles in viewfiles:
file= os.path.join(path, allfiles)
text=open(file, "r")
for line in text:
if re.match("DECRYPT_I", line):
print line,
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Regex Python Help gdotoli@gmail.com - 2015-03-24 11:13 -0700
Re: Regex Python Help Skip Montanaro <skip.montanaro@gmail.com> - 2015-03-24 13:23 -0500
Re: Regex Python Help Gary Herron <gherron@digipen.edu> - 2015-03-24 11:25 -0700
Re: Regex Python Help Gregg Dotoli <gdotoli@gmail.com> - 2015-03-24 12:10 -0700
Re: Regex Python Help Rob Gaddi <rgaddi@technologyhighland.invalid> - 2015-03-24 19:40 +0000
Re: Regex Python Help Gregg Dotoli <gdotoli@gmail.com> - 2015-03-24 12:22 -0700
Re: Regex Python Help Vincent Vande Vyvre <vincent.vande.vyvre@telenet.be> - 2015-03-24 20:40 +0100
Re: Regex Python Help Skip Montanaro <skip.montanaro@gmail.com> - 2015-03-24 14:35 -0500
Re: Regex Python Help Vincent Vande Vyvre <vincent.vande.vyvre@telenet.be> - 2015-03-24 20:38 +0100
Re: Regex Python Help smap <askme.first@thankyouverymuch.invalid> - 2015-03-28 07:53 +0000
Re: Regex Python Help Gregg Dotoli <gdotoli@gmail.com> - 2015-03-24 12:43 -0700
Re: Regex Python Help Rob Gaddi <rgaddi@technologyhighland.invalid> - 2015-03-24 19:53 +0000
Re: Regex Python Help Gregg Dotoli <gdotoli@gmail.com> - 2015-03-24 13:45 -0700
Re: Regex Python Help Terry Reedy <tjreedy@udel.edu> - 2015-03-24 15:53 -0400
Re: Regex Python Help Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-25 12:43 +1100
Re: Regex Python Help Gregg Dotoli <gdotoli@gmail.com> - 2015-03-25 07:53 -0700
Re: Regex Python Help Denis McMahon <denismfmcmahon@gmail.com> - 2015-03-25 20:34 +0000
Re: Regex Python Help Gregg Dotoli <gdotoli@gmail.com> - 2015-03-25 14:19 -0700
Re: Regex Python Help Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-03-25 22:15 +0000
Re: Regex Python Help Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-26 10:10 +1100
Re: Regex Python Help Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-03-25 23:50 +0000
Re: Regex Python Help Terry Reedy <tjreedy@udel.edu> - 2015-03-26 01:00 -0400
Re: Regex Python Help Denis McMahon <denismfmcmahon@gmail.com> - 2015-03-26 12:04 +0000
csiph-web