[Tutor] Syntax Problem

Dave Angel davea at ieee.org
Sat Jul 25 12:10:53 CEST 2009


Jesse Harris wrote:
> for d in Decks.all(): #loop thru all available decks
>           self.response.out.write('<OPTION>'+d.name) 
>           self.response.out.write('<OPTION>'+d.description)
> self.response.out.write('</SELECT></div>')
> self.response.out.write('<div style="float:left">')
>
> <type 'exceptions.SyntaxError'>: invalid syntax (main.py, line 206)
>
>       args =
> ('invalid syntax', (r'C:\Program Files\Google\google_appengine\bangagears2\main.py', 206, 78, "                \t\tself.response.out.write('<OPTI...elf.response.out.write('<OPTION>'+d.description)\n"))
>
>       filename =
> r'C:\Program Files\Google\google_appengine\bangagears2\main.py'
>
>       lineno =
> 206
>
>       message =
> ''
>
>       msg =
> 'invalid syntax'
>
>       offset =
> 78
>
>       print_file_and_line =
> None
>
>       text =
> "                \t\tself.response.out.write('<OPTI...elf.response.out.write('<OPTION>'+d.description)\n"
>
>
>
>   
There are so many things wrong I'm not sure where to begin.

This excerpt of code isn't nearly enough to compile, since it references 
lots of symbols not defined.  And it's not formatted the same as your 
original.  Your original definitely had tabs in it, as well as the 
normal spaces for indenting, which is asking for trouble.  You shouldn't 
use the name 'self' when you're not inside a method definition (it's not 
an error, but it is sure confusing).


If I take my best guess at some class and method definitions, and paste 
this fragment into a method of a class, and fix the indenting to what I 
might guess you were planning, it compiles and runs without problems.  
But I expected that, since the error is supposed to be in column 78, and 
you didn't have that many columns in your posting.  Even if I add back 
in the two tabs you omitted, and count them as eight characters each, 
we're still ten characters short.

Finally the error line displayed is not included in your excerpt.  Since 
the error message used ellipses in its quoting of the line, we can't see 
it all.  But if I had to guess, I'd say it was a case of mismatched 
quotation marks.  Or two lines combined together (note the two 
occurrences of self.response.out.write() )

DaveA



More information about the Tutor mailing list