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


Groups > comp.lang.python > #87891

Re: Regex Python Help

Date 2015-03-24 11:25 -0700
From Gary Herron <gherron@digipen.edu>
Subject Re: Regex Python Help
References <099b0ca2-1f5e-4eb4-a7d0-d8210bcca51a@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.109.1427222047.10327.python-list@python.org> (permalink)

Show all headers | View raw


On 03/24/2015 11:13 AM, gdotoli@gmail.com 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

You appear to be using Python3, but have written code for Python2.

There are a number of differences between the two, but your particular 
error runs into the different syntax for prints.

Python2: print line # This is a statement
Python3  print(line)  # This is a procedure call



-- 
Dr. Gary Herron
Department of Computer Science
DigiPen Institute of Technology
(425) 895-4418

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