Python concatenation Question problem
Gabriel Cooper
gabriel.cooper at mediapulse.com
Tue Oct 5 17:05:39 EDT 2004
Kory Wheatley wrote:
> I have the the following string variable called *mlist *that contains
> the value *ccinfolist *here is what I've tried to do to join this
> variable with another string value.
>
> First attempt
>
> url = http://www.isu.edu + mlist
>
> error I receive:
> *TypeError: cannot add type "instance" to string mlist*
Well, the first line you mention above, the URL itself should have been
in quotes. However I assume you actually did so and just didn't type
them into the email since otherwise you'd have a syntax error! At any
rate, you need to figure out what exactly "mlist" is. Since it says it's
an "instance" that means it's an instance of a class, and not a string.
So... If this sounds correct, then you'll need to simply use this instead:
url = "http://www.isu.edu" + str(mlist)
You'll probably need to define the __str__ method if it's not defined
already in your class.
Gabriel.
More information about the Python-list
mailing list