[Tutor] Write string into files

Eric Pederson whereU at now.com
Wed Oct 6 09:37:27 CEST 2004


Ms Soo Chong <s4046441 at student.uq.edu.au>
 
<snip>

> 
> #####################################################
> A problem occurred in a Python script. Here is the
> sequence of function calls leading up to the error,
> in the order they occurred.
> 
>  /var/www/cgi-bin/sf/run_des.py
>   192         str += "<blame>" + blame + "</blame>"

<snip>

> TypeError: cannot concatenate 'str' and 'NoneType'
> objects


I believe directly above is the key error message: you can not add a string to (nothing).  Trying to concatenate a string to a null object is a type mismatch.  Not sure what the optimal way to handle this is, but note the following interactive session, which might provide you some hints.

>>> nothing=None
>>> print nothing
None
>>> if (nothing == None):
	nothing=""

>>> print nothing

>>> something="<delimiter>"+nothing+"<delimiter>"
>>> print something
<delimiter><delimiter>






Eric Pederson
http://www.songzilla.blogspot.com
:::::::::::::::::::::::::::::::::::
domainNot="@something.com"
domainIs=domainNot.replace("s","z")
ePrefix="".join([chr(ord(x)+1) for x in "do"])
mailMeAt=ePrefix+domainIs
:::::::::::::::::::::::::::::::::::


More information about the Tutor mailing list