Hi; I have the following code: cursor.execute('describe %s;' % store) colFields, colFieldValues = [itm[0] for itm in cursor], [itm[1] for itm in cursor] ... for col in colFields: ... print '<b>%s: </b>%s<br />\n' % (col, colValue[0])
Don't worry about the colValue[0]. In fact, the code throws no errors. However, when colValue[0] (which is called from the MySQL table) is a set as opposed to, say, a string, it prints out: Set([]) which is natural, because there isn't anything in the set. What I'm trying to accomplish, however, is to offer a select of the possible values of that set as are available from the describe and caught in the tuple colFieldValues. For example, if I go to print, say, colFieldValues[20], which is a set, it prints out the whole set: set('Extra-small','Small','Medium','Large','XLarge','XXLarge','XXXLarge') But if I print out colFieldValues[20][0], it prints out "s". Now, I suppose I could do something like lop off the ends of colFieldValues[20] thus: tmp = string.split(colFieldValues[20][4:-2], "','") but boy that's inelegant! Any better suggestions? Also, how can I test for it? It's an instance of string. How do I know if it's a set? TIA, Victor
-- http://mail.python.org/mailman/listinfo/python-list