type error on porting outfile.write

Eric McCoy ctr2sprt at comcast.net
Wed Dec 21 04:11:01 CET 2005


pmiller at gnf.org wrote:
> I ported my code from the development to
> application platform, I found a "type error"
> on a fileout statement:

> outfile.write(object.id +",")

What is the type of object.id?  I'm guessing an integer.  The exception
should tell you, e.g.:

  TypeError: unsupported operand type(s) for +: 'int' and 'str'

If I'm right, you can do this:

  outfile.write("%d," % (object.id))

Though probably the better solution is to find out what code is
assigning an unexpected value to object.id.




More information about the Python-list mailing list