[Tutor] Can't find error :-(

Lisi lisi.reisz at gmail.com
Sun Aug 28 14:34:05 CEST 2011


On Sunday 28 August 2011 13:01:38 Peter Otten wrote:
> Lisi wrote:
> > Here is the error message:
> > /usr/local/bin/AddressBook: line 6: syntax error near unexpected token
> > `(' /usr/local/bin/AddressBook: line 6: `name = raw_input("Type the Name
> > - leave blank to finish")'
> >
> > (sorry KMail wrapped it.)
> >
> > Here is what I typed:
> > name = raw_input("Type the Name - leave blank to finish")
> >
> > Here is what I was copying:
> > name = raw_input("Type the Name - leave blank to finish")
> >
> > Help!!   All three are copied and pasted from their relevant places to
> > eliminate mis-copying at this stage.  What have I miscopied??  The
> > original and my copy look to me *exactly* the same.
>
> That's an error message by your shell. You made your script executable, but
> forgot to add something like
>
> #!/usr/bin/env python
>
> as its first line.
>
> NB. it's quite common that an error originates before the place where the
> interpreter complains; it would have been a good idea to post the five
> lines before the explicitly erroneous one, too.

Thanks to both.  I opened up the file to try retyping the ", although I had in 
fact typed it - the copying and pasting was into the email to ensure that I 
did not introduce any errors at that stage.  But looking at the file, I 
realised that I had forgotten my shebang line - and had put it right before I 
read this answer.  

I am very grateful to you both.  I had realised that the error might be 
somewhere other than where it is indicated because Alan had already told me 
so - but had not understood that it could be, not only in a different place, 
but quite a way away.  Not even when I put this right.  So thanks for that, 
Peter, and thank you again, both of you.

For future reference, how would I set about changing the encoding for just one 
character or file?  I don't really want to change the encoding I use system 
wide.

Lisi


More information about the Tutor mailing list