Re: Manipulating MySQL Sets

2009-12-13 Thread Victor Subervi
On Sat, Dec 12, 2009 at 6:35 PM, Carsten Haese carsten.ha...@gmail.comwrote: 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

Re: Manipulating MySQL Sets

2009-12-13 Thread Sebastian Bassi
On Sun, Dec 13, 2009 at 12:48 PM, Victor Subervi victorsube...@gmail.com wrote: Who said I was expecting a string? I don't know what I'm expecting! 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. You

Re: Manipulating MySQL Sets

2009-12-13 Thread Carsten Haese
Victor Subervi wrote: On Sat, Dec 12, 2009 at 6:35 PM, Carsten Haese carsten.ha...@gmail.com mailto:carsten.ha...@gmail.com 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

Re: Manipulating MySQL Sets

2009-12-13 Thread Victor Subervi
On Sun, Dec 13, 2009 at 11:36 AM, Carsten Haese carsten.ha...@gmail.comwrote: 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

Re: Manipulating MySQL Sets

2009-12-13 Thread Robert P. J. Day
On Sun, 13 Dec 2009, Victor Subervi wrote: On Sun, Dec 13, 2009 at 11:36 AM, Carsten Haese carsten.ha...@gmail.com wrote: 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

Re: Manipulating MySQL Sets

2009-12-13 Thread Victor Subervi
On Sun, Dec 13, 2009 at 11:56 AM, Robert P. J. Day rpj...@crashcourse.cawrote: On Sun, 13 Dec 2009, Victor Subervi wrote: On Sun, Dec 13, 2009 at 11:36 AM, Carsten Haese carsten.ha...@gmail.com wrote: I don't know what I'm expecting! That statement is the most succinct

Re: Manipulating MySQL Sets

2009-12-13 Thread Robert P. J. Day
On Sun, 13 Dec 2009, Victor Subervi wrote: On Sun, Dec 13, 2009 at 11:56 AM, Robert P. J. Day rpj...@crashcourse.ca wrote: On Sun, 13 Dec 2009, Victor Subervi wrote: On Sun, Dec 13, 2009 at 11:36 AM, Carsten Haese carsten.ha...@gmail.com wrote:       I

Re: Manipulating MySQL Sets

2009-12-13 Thread Carsten Haese
Victor Subervi wrote: I need to get at the individual elements of the set (that which is between the single quotes). It's not quite clear what you mean by get at the individual elements, so I'll just show you a couple of things you can do to a set, and maybe one of them comes close to what you

Re: Manipulating MySQL Sets

2009-12-13 Thread Victor Subervi
On Sun, Dec 13, 2009 at 11:26 AM, Sebastian Bassi sba...@clubdelarazon.orgwrote: On Sun, Dec 13, 2009 at 12:48 PM, Victor Subervi victorsube...@gmail.com wrote: Who said I was expecting a string? I don't know what I'm expecting! I need to be able to parse this thing, whatever it is. You

Re: Manipulating MySQL Sets

2009-12-13 Thread Sebastian Bassi
On Sun, Dec 13, 2009 at 2:10 PM, Carsten Haese carsten.ha...@gmail.com wrote: from sets import Set aSet = Set(['Small', 'Extra-small', 'Medium']) You don't need to import Set since it is built in now: a=set([1,2,2,3,4,5]) a set([1, 2, 3, 4, 5]) (I have Python 2.6.2 but I think that this is

Re: Manipulating MySQL Sets

2009-12-13 Thread Victor Subervi
On Sun, Dec 13, 2009 at 12:10 PM, Carsten Haese carsten.ha...@gmail.comwrote: Victor Subervi wrote: I need to get at the individual elements of the set (that which is between the single quotes). It's not quite clear what you mean by get at the individual elements, so I'll just show you a

Re: Manipulating MySQL Sets

2009-12-13 Thread Victor Subervi
On Sun, Dec 13, 2009 at 12:39 PM, Victor Subervi victorsube...@gmail.comwrote: PS: I have another field that's a datetime with the same problem. How do I parse and otherwise work with that? TIA, V -- http://mail.python.org/mailman/listinfo/python-list

Re: Manipulating MySQL Sets

2009-12-13 Thread MRAB
Victor Subervi wrote: On Sun, Dec 13, 2009 at 11:26 AM, Sebastian Bassi sba...@clubdelarazon.org mailto:sba...@clubdelarazon.org wrote: On Sun, Dec 13, 2009 at 12:48 PM, Victor Subervi victorsube...@gmail.com mailto:victorsube...@gmail.com wrote: Who said I was expecting a

Re: Manipulating MySQL Sets

2009-12-13 Thread Victor Subervi
On Sun, Dec 13, 2009 at 12:40 PM, Victor Subervi victorsube...@gmail.comwrote: On Sun, Dec 13, 2009 at 12:39 PM, Victor Subervi victorsube...@gmail.comwrote: PS: I have another field that's a datetime with the same problem. How do I parse and otherwise work with that? I have yet another

Re: Manipulating MySQL Sets

2009-12-13 Thread MRAB
Victor Subervi wrote: On Sun, Dec 13, 2009 at 12:39 PM, Victor Subervi victorsube...@gmail.com mailto:victorsube...@gmail.com wrote: PS: I have another field that's a datetime with the same problem. How do I parse and otherwise work with that? Look at the documentation for the datetime

Re: Manipulating MySQL Sets

2009-12-13 Thread MRAB
Victor Subervi wrote: On Sun, Dec 13, 2009 at 12:40 PM, Victor Subervi victorsube...@gmail.com mailto:victorsube...@gmail.com wrote: On Sun, Dec 13, 2009 at 12:39 PM, Victor Subervi victorsube...@gmail.com mailto:victorsube...@gmail.com wrote: PS: I have another field that's a

Re: Manipulating MySQL Sets

2009-12-13 Thread Dave Angel
Victor Subervi wrote: On Sun, Dec 13, 2009 at 12:10 PM, Carsten Haese carsten.ha...@gmail.comwrote: Victor Subervi wrote: I need to get at the individual elements of the set (that which is between the single quotes). It's not quite clear what you mean by get at the individual

Re: Manipulating MySQL Sets

2009-12-12 Thread Carsten Haese
Victor Subervi wrote: Hi; What type does python consider a MySQL Set?? Let's take a look: import MySQLdb conn = MySQLdb.connect(db=carsten, user=blah, passwd=blah) cur = conn.cursor() cur.execute( ... create table pizza ( ... id integer, ... toppings

Re: Manipulating MySQL Sets

2009-12-12 Thread Victor Subervi
On Sat, Dec 12, 2009 at 5:11 PM, Carsten Haese carsten.ha...@gmail.comwrote: Victor Subervi wrote: Hi; What type does python consider a MySQL Set?? Let's take a look: import MySQLdb conn = MySQLdb.connect(db=carsten, user=blah, passwd=blah) cur = conn.cursor() cur.execute( ...

Re: Manipulating MySQL Sets

2009-12-12 Thread Victor Subervi
On Sat, Dec 12, 2009 at 6:07 PM, Victor Subervi victorsube...@gmail.comwrote: On Sat, Dec 12, 2009 at 5:11 PM, Carsten Haese carsten.ha...@gmail.comwrote: Victor Subervi wrote: Hi; What type does python consider a MySQL Set?? Let's take a look: import MySQLdb conn =

Re: Manipulating MySQL Sets

2009-12-12 Thread Carsten Haese
Victor Subervi wrote: Yep, sure does, but it isn't. Again: if isinstance(colValue[0], (str, int, long, float, long, complex, unicode, list, buffer, xrange, tuple)): pass else: print 'XXX' and those strings printed triple-X. It

Re: Manipulating MySQL Sets

2009-12-12 Thread MRAB
Victor Subervi wrote: On Sat, Dec 12, 2009 at 5:11 PM, Carsten Haese carsten.ha...@gmail.com mailto:carsten.ha...@gmail.com wrote: Victor Subervi wrote: Hi; What type does python consider a MySQL Set?? Let's take a look: [snip] Looks like a string to me. Yep,

Re: Manipulating MySQL Sets

2009-12-12 Thread Carsten Haese
Victor Subervi wrote: PS: Changed the code to this: elif col[:3] != 'pic': if isinstance(colValue[0], (str, int, long, float, long, complex, unicode, list, buffer, xrange, tuple)): pass else: print 'XXX'