Re[2]: [Tutor] invalid syntax? huh!?!

Ray Leggett rlegge@tc3net.com
Fri, 18 Oct 2002 13:58:36 -0400


Yeah, i saw that after i posted.  But I fixed the two colons, and I still
get the same error message,.

----- Original Message -----
From: "python" <python@inkedmn.net>
To: "Jeff Shannon" <jeff@ccvcorp.com>
Cc: "Ray Leggett" <rlegge@tc3net.com>; <tutor@python.org>
Sent: Friday, October 18, 2002 1:57 PM
Subject: Re[2]: [Tutor] invalid syntax? huh!?!


>
> you need a colon at the end of this line:
>
> for line in fp.readlines():
>
>
> brett
>
> JS> Ray Leggett wrote:
>
> >> File "C:\scripts\modscan.py", line 16
> >>   for line in fp.readlines()
> >>   ^
> >> SyntaxError:  invalid syntax
> >>
> >> [....]
>
> >> def ScanModule(ModuleToScan):
> >>  fp = open(ModuleToScan)
> >>   for line in fp.readlines()
> >>    if ScanClass.search(line):
>
> JS> [...]
>
> JS> If you get a syntax error at the beginning of a line, then it's often
an
> JS> indication that there's something wrong with the *previous* line, line
> JS> termination, etc.
>
> JS> In this case, you've got an indentation problem.  The 'for ...' should
line up
> JS> with the 'fp = ...' in the previous line.  There's no change of
program flow,
> JS> so there should be no change of indentation.  There's another
indentation
> JS> problem elsewhere in your code, too -- the nested 'if ...' in your
'else...'
> JS> clause needs to have the line below it ('print line') indented.  These
things
> JS> will probably be easier to spot if you use standard 4-space
indentation
> JS> instead of the single-space indentation that you seem to be using.
(Or is
> JS> that just various mailers munging tabs?  Either way, I recommend 4
spaces,
> JS> since that's the Pythonlabs standard... :) )
>
> JS> There's another syntax error that'll bite you as soon as you fix this
one, too
> JS> -- the for statement needs to be terminated with a colon, which you've
> JS> accidentally left out.
>
> JS> Jeff Shannon
> JS> Technician/Programmer
> JS> Credit International
>
>
>
> JS> _______________________________________________
> JS> Tutor maillist  -  Tutor@python.org
> JS> http://mail.python.org/mailman/listinfo/tutor
>