Str and instance concatanation error

Newt newt_e at blueyonder.co.uk
Mon Nov 4 18:01:05 EST 2002


I keep getting the following error when trying to write to a file.

Traceback (most recent call last):
  File "C:\Python22\lib\lib-tk\Tkinter.py", line 1292, in __call__
    return apply(self.func, args)
  File "D:\py_stuff\curry.py", line 14, in __call__
    return self.fun(*(self.pending + args), **kw)
  File "D:\py_stuff\chaz.py", line 144, in savefile
    gv.save_char()
  File "D:\py_stuff\globals.py", line 96, in save_char
    file.write('<creator>' + self.creator + '</creator>')
TypeError: cannot concatenate 'str' and 'instance' objects

This occurs in a class module (called globals.py). This is used to hold all
my global variables, and also has a method (called save_char) to write these
to a file.

self.creator is initialised in the __init__ as "". Should I create it as a
stringVar instead, or am I doing something incredibly stupid.

TIA

Newt





More information about the Python-list mailing list