Manipulating MySQL Sets

Carsten Haese carsten.haese at
Sun Dec 13 17:36:44 CET 2009

Victor Subervi wrote:
> On Sat, Dec 12, 2009 at 6:35 PM, Carsten Haese <carsten.haese at
> <mailto:carsten.haese at>> wrote:
>     The traceback helpfully shows us that colValue is a 1-tuple whose zeroth
>     entry, colValue[0], is an actual bona-fide Python Set object. Such
>     objects aren't indexable, because sets are unordered. That still doesn't
>     tell us where colValue is coming from, though, so why it is a Python Set
>     object when you expected it to be a string remains an unsolved mystery.
> Who said I was expecting a string?

You did, indirectly, since you were expecting the value to be the
contents of a MySQL SET column, which as far as I can determine should
be returned as a string. (Recall that I showed a complete example that
demonstrates this.) The fact that you don't get a string is something
that you ought to be interested in investigating.

> I don't know what I'm expecting!

That statement is the most succinct summary of the root cause of all
your problems. If you don't know what to expect, how could you possibly
write code that produces what you expect? (Don't answer this question.
It's a rhetorical question.)

> I need to be able to parse this thing, whatever it is. You say it's a
> Python Set object. How do I parse it? Googling has been disappointing.

What do you mean by "parse"? What is the end result you are hoping to
achieve by "parsing" a Set object?

Carsten Haese

More information about the Python-list mailing list