cannot concatenate 'str' and 'list' objects

Chris Gonnerman chris at gonnerman.org
Sat Sep 15 12:13:55 EDT 2012


On 09/15/2012 10:23 AM, Νικόλαος Κούρας wrote:
> I swicthed back my code to:  f = open( '../' + page )
>
> and http://superhost.gr works which means that line gets parsed correctly.
>
> Only when i post data to the text area boxes iam getting the error:
>
> cannot concatenate 'str' and 'list' objects
>
> how is this possible to work before and NOT work when i enter data to the page for storing to the database?
You really need to add some print-type diagnostics to your script 
temporarily, just to see what you are actually getting for parameters. 
For example, put this:

print "Content-type: text/plain\n"

near the top so you can get a source printout, then add

print `page`

just before you attempt your open() call so you can see what the exact 
Python representation of page is. Do similarly for other problems in 
your code. Don't leave such an "instrumented" copy of your CGI script on 
your site for very long and you should be safe.

Also, consider using the built-in cgi traceback feature in your scripts, 
at least while you are debugging them (though you probably want to 
remove the traceback after you are "in production").

-- Chris.



More information about the Python-list mailing list