Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed0.kamp.net!newsfeed.kamp.net!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.81.MISMATCH!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'syntax': 0.04; 'root': 0.05; 'string.': 0.05; 'subject:Python': 0.06; 'correct.': 0.07; 'python3': 0.07; 'sys': 0.07; 'advance': 0.07; 'runs': 0.10; 'subject:Help': 0.11; '"r")': 0.16; 'filesystem': 0.16; 'parentheses': 0.16; 'syntaxerror:': 0.16; 'two,': 0.16; 'wrote:': 0.18; 'written': 0.21; 'help.': 0.21; 'import': 0.22; 'print': 0.22; 'creating': 0.23; 'header:User-Agent:1': 0.23; 'error': 0.23; 'header:In-Reply-To:1': 0.27; 'appear': 0.29; 'am,': 0.29; 'statement': 0.30; 'code': 0.31; 'gary': 0.31; 'file': 0.32; 'skip:- 50': 0.35; 'tool': 0.35; 'but': 0.35; 'there': 0.35; 'should': 0.36; 'received:10': 0.37; 'thank': 0.38; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'simple': 0.61; 'email addr:gmail.com': 0.63; 'different': 0.65; 'charset:windows-1252': 0.65; 'between': 0.67; 'line,': 0.68; 'institute': 0.72; 'received:10.10': 0.74; 'received:204': 0.75; 'dr.': 0.77; 'gregg': 0.84; 'differences': 0.93 Date: Tue, 24 Mar 2015 11:25:11 -0700 From: Gary Herron User-Agent: Mozilla/5.0 (X11; Linux x86_64; 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> In-Reply-To: <099b0ca2-1f5e-4eb4-a7d0-d8210bcca51a@googlegroups.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.19 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 44 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1427222047 news.xs4all.nl 2892 [2001:888:2000:d::a6]:58711 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:87891 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