Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #87896

Re: Regex Python Help

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <vincent.vande.vyvre@telenet.be>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'syntax': 0.04; 'root': 0.05; 'string.': 0.05; 'tree': 0.05; 'subject:Python': 0.06; 'correct.': 0.07; 'sys': 0.07; 'advance': 0.07; 'subject:Help': 0.11; '"r")': 0.16; '24,': 0.16; 'doesnt': 0.16; 'filesystem': 0.16; 'finishes': 0.16; 'from:name:vincent vande vyvre': 0.16; 'parentheses': 0.16; 'received:195.130': 0.16; 'received:195.130.137': 0.16; 'received:telenet-ops.be': 0.16; 'syntaxerror:': 0.16; '\xe9crit': 0.16; 'wrote:': 0.18; 'help.': 0.21; '>>>': 0.22; 'import': 0.22; 'print': 0.22; 'creating': 0.23; 'header:User-Agent:1': 0.23; 'error': 0.23; 'script': 0.25; 'header:In-Reply-To:1': 0.27; 'quickly': 0.29; 'indentation': 0.31; 'search.': 0.31; 'file': 0.32; 'skip:- 50': 0.35; 'tool': 0.35; 'but': 0.35; 'should': 0.36; 'too': 0.37; 'thank': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'march': 0.61; 'simple': 0.61; 'charset:windows-1252': 0.65; 'header:Reply- To:1': 0.67; 'line,': 0.68; 'reply-to:no real name:2**0': 0.71; 'walk': 0.74; '2015': 0.84; 'gregg': 0.84
Date Tue, 24 Mar 2015 20:40:40 +0100
From Vincent Vande Vyvre <vincent.vande.vyvre@telenet.be>
Reply-To vincent.vandevyvre@oqapy.eu
User-Agent Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.5.0
MIME-Version 1.0
To python-list@python.org
Subject Re: Regex Python Help
References <099b0ca2-1f5e-4eb4-a7d0-d8210bcca51a@googlegroups.com> <43835701-a845-4a59-8936-0be236dfa59f@googlegroups.com> <5511BD4E.6010701@telenet.be>
In-Reply-To <5511BD4E.6010701@telenet.be>
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 8bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.19
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.111.1427226044.10327.python-list@python.org> (permalink)
Lines 58
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1427226044 news.xs4all.nl 2845 [2001:888:2000:d::a6]:48642
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:87896

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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