Re: Manipulating MySQL Sets

2009-12-13 Thread Dave Angel
Victor Subervi wrote: On Sun, Dec 13, 2009 at 12:10 PM, Carsten Haese wrote: 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

Re: Manipulating MySQL Sets

2009-12-13 Thread MRAB
Victor Subervi wrote: On Sun, Dec 13, 2009 at 12:40 PM, Victor Subervi mailto:victorsube...@gmail.com>> wrote: On Sun, Dec 13, 2009 at 12:39 PM, Victor Subervi mailto:victorsube...@gmail.com>> wrote: PS: I have another field that's a datetime with the same problem. How do I par

Re: Manipulating MySQL Sets

2009-12-13 Thread MRAB
Victor Subervi wrote: On Sun, Dec 13, 2009 at 12:39 PM, Victor Subervi 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 class. -- http://mail.pyth

Re: Manipulating MySQL Sets

2009-12-13 Thread Victor Subervi
On Sun, Dec 13, 2009 at 12:40 PM, Victor Subervi wrote: > On Sun, Dec 13, 2009 at 12:39 PM, Victor Subervi > wrote: > > 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 problem with this. Once I've determined it

Re: Manipulating MySQL Sets

2009-12-13 Thread MRAB
Victor Subervi wrote: On Sun, Dec 13, 2009 at 11:26 AM, Sebastian Bassi mailto:sba...@clubdelarazon.org>> wrote: On Sun, Dec 13, 2009 at 12:48 PM, Victor Subervi mailto:victorsube...@gmail.com>> wrote: > Who said I was expecting a string? I don't know what I'm expecting! I need

Re: Manipulating MySQL Sets

2009-12-13 Thread Victor Subervi
On Sun, Dec 13, 2009 at 12:39 PM, Victor Subervi wrote: 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 Victor Subervi
On Sun, Dec 13, 2009 at 12:10 PM, Carsten Haese wrote: > 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 thin

Re: Manipulating MySQL Sets

2009-12-13 Thread Sebastian Bassi
On Sun, Dec 13, 2009 at 2:10 PM, Carsten Haese 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 availabl

Re: Manipulating MySQL Sets

2009-12-13 Thread Victor Subervi
On Sun, Dec 13, 2009 at 11:26 AM, Sebastian Bassi wrote: > On Sun, Dec 13, 2009 at 12:48 PM, Victor Subervi > 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

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 y

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 > wrote: > On Sun, 13 Dec 2009, Victor Subervi wrote: > > > On Sun, Dec 13, 2009 at 11:36 AM, Carsten Haese > > > wrote: > >       > I don't know what I'm expecting! >

Re: Manipulating MySQL Sets

2009-12-13 Thread Victor Subervi
On Sun, Dec 13, 2009 at 11:56 AM, Robert P. J. Day wrote: > On Sun, 13 Dec 2009, Victor Subervi wrote: > > > On Sun, Dec 13, 2009 at 11:36 AM, Carsten Haese > > > wrote: > > > I don't know what I'm expecting! > > > > That statement is the most succinct summary of the root cause of all > > y

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 > 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 you > possibly wri

Re: Manipulating MySQL Sets

2009-12-13 Thread Victor Subervi
On Sun, Dec 13, 2009 at 11:36 AM, Carsten Haese 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 you possibly > write code that produces what you expect? (Don't answer t

Re: Manipulating MySQL Sets

2009-12-13 Thread Carsten Haese
Victor Subervi wrote: > On Sat, Dec 12, 2009 at 6:35 PM, Carsten Haese > 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,

Re: Manipulating MySQL Sets

2009-12-13 Thread Sebastian Bassi
On Sun, Dec 13, 2009 at 12:48 PM, Victor Subervi 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 can walk thought a set

Re: Manipulating MySQL Sets

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

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' >

Re: Manipulating MySQL Sets

2009-12-12 Thread MRAB
Victor Subervi wrote: On Sat, Dec 12, 2009 at 5:11 PM, Carsten Haese > 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, sure does, but it isn't.

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 tri

Re: Manipulating MySQL Sets

2009-12-12 Thread Victor Subervi
On Sat, Dec 12, 2009 at 6:07 PM, Victor Subervi wrote: > On Sat, Dec 12, 2009 at 5:11 PM, Carsten Haese wrote: > >> 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="b

Re: Manipulating MySQL Sets

2009-12-12 Thread Victor Subervi
On Sat, Dec 12, 2009 at 5:11 PM, Carsten Haese wrote: > 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 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, ... toppin

Manipulating MySQL Sets

2009-12-12 Thread Victor Subervi
Hi; What type does python consider a MySQL Set?? if isinstance(colValue[0], (str, int, long, float, long, complex, unicode, list, buffer, xrange, tuple)): pass else: print 'XXX' And the following fields pass through this net: Set and dat