[Tutor] WHY IT DI DIS?

Grimmtooth grimmtoothtoo@yahoo.com
Thu, 27 Dec 2001 22:46:11 -0500


> OK, WHY DOES IT DO THIS?
>
> ns# ./TLwebmgr.py
>   File "./TLwebmgr.py", line 35
>     print "<a href=" + \" + webpath + "cgi-bin/commander.py?list=" + x +
> \" + '>' + x + "</a> ", descriptor(x) + '<P>'
>
> ^
> SyntaxError: invalid token

Looks like a mismatched quote, MAYBE, hard to tell for sure.

It MIGHT help to use substitution rather than concatenating all that stuff
together. It has bitten me in the backside more times than I care to tell
:-) If you're familiar with 'c' formatting codes, it follows pretty much the
same pattern except in how the arguments are indicated. Example (and not
necessarilly what you intended):

print "<a href=\"%scgi-bin/commander.py?list=%s\">%s</a>%s<P>" % (webpath,
x, x, descriptor(x))

Each of the items in the parenthesis goes into the 'bucket' designated by a
%s in the string itself, respectively in order of appearance, so to speak.



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com