The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

import-bot (20211) [Avatar] Offline
#1
[Originally posted by vespaman]

Hi, I am trying to run the example on page 133 (second edition). I am running
Python 1.5.2 on Linux Red hat 7.2 but keep getting a syntax error as shown
below. Can anyone tell me what it means? Thanks, John.

>>> fileobject = open("access.log.1",'r')
>>> count=0
>>> while fileobject.readline() != "":
... count = count + 1
... print count
File "<stdin>", line 3
print count
^
SyntaxError: invalid syntax
>>>
import-bot (20211) [Avatar] Offline
#2
Re: Invalid syntax error
[Originally posted by vespaman]

Hi,
I decided I needed to hit Ctrl-C to get a keyboard interrupt immediately
before typing "print count" and now I don't get the error .

>>> while fileobject.readline() != "" :
... count = count + 1
...
KeyboardInterrupt
>>> print count
0

Cheers,
John

> Hi, I am trying to run the example on page 133 (second edition). I am running
> Python 1.5.2 on Linux Red hat 7.2 but keep getting a syntax error as shown
> below. Can anyone tell me what it means? Thanks, John.
>
> >>> fileobject = open("access.log.1",'r')
> >>> count=0
> >>> while fileobject.readline() != "":
> ... count = count + 1
> ... print count
> File "<stdin>", line 3
> print count
> ^
> SyntaxError: invalid syntax
> >>>
import-bot (20211) [Avatar] Offline
#3
Re: Invalid syntax error - Sorry everyone
[Originally posted by vespaman]

My apologies! I read through some previous answers and found I needed to hit
the "Enter" button twice to properly unindent! Sorry for the stupid question
in the first place smilie