[Tutor] Write string into files

Ms Soo Chong s4046441 at student.uq.edu.au
Wed Oct 6 09:16:47 CEST 2004


Hi,


I'm trying to combine a bunch of data from a form
into a string and write it into a file. It works
fine if the user input each and every fields but it
showed the following error if the user did not. And 
these fields are not compulsory, they may or may not 
have values. So how should I do it? Btw, the way I'm
doing it now is kinda of longwinded so if anyone can
suggest me a better deal of grabbing all the data
into a file straight, it would be very nice.

Any help is greatly appreciated.

Thank you.

Shufen

#####################################################
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>"
+ "\n"
  193         str += "<date_string>" + date_string +
"</date_string>" + "\n"
  194         str += "<nozzle>" + nozzle +
"</nozzle>" + "\n"
  195         str += "<shocktube>" + shocktube +
"</shocktube>" + "\n"
  196         str += "<reservoir>" + reservoir +
"</reservoir>" + "\n"
str = '<facility_name>T4 Shock
Tunnel</facility_name>\n<...F/PJ</blame>\n<date_string>05/10/04</date_string>\n',
nozzle = None

TypeError: cannot concatenate 'str' and 'NoneType'
objects
      __doc__ = 'Inappropriate argument type.'
      __getitem__ = <bound method
TypeError.__getitem__ of <exceptions.TypeError
instance at 0x81d31dc>>
      __init__ = <bound method TypeError.__init__ of
<exceptions.TypeError instance at 0x81d31dc>>
      __module__ = 'exceptions'
      __str__ = <bound method TypeError.__str__ of
<exceptions.TypeError instance at 0x81d31dc>>
      args = ("cannot concatenate 'str' and
'NoneType' objects",) 

######################################################


-------------- next part --------------
A non-text attachment was scrubbed...
Name: run_des.py
Type: application/octet-stream
Size: 9509 bytes
Desc: not available
Url : http://mail.python.org/pipermail/tutor/attachments/20041006/54e3c8ca/run_des-0001.obj


More information about the Tutor mailing list