Manipulating MySQL Sets

MRAB python at mrabarnett.plus.com
Sun Dec 13 13:31:58 EST 2009


Victor Subervi wrote:
> On Sun, Dec 13, 2009 at 11:26 AM, Sebastian Bassi 
> <sbassi at clubdelarazon.org <mailto:sbassi at clubdelarazon.org>> wrote:
> 
>     On Sun, Dec 13, 2009 at 12:48 PM, Victor Subervi
>     <victorsubervi at gmail.com <mailto:victorsubervi at 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 can walk thought a set object like any iterable object like
> 
>     for x in myset:
>        #do something like parse it.
> 
>     If you want to slice it, convert it to a list:
> 
>     mylist = list(myset)
> 
>     Or read about sets:
>     http://docs.python.org/library/sets.html
> 
> 
> Both the following solutions threw the same error:
> 
>                 newCol = list(colValue[0])
>                 print newCol[0:20]
> 
> and
> 
>                 for x in colValue[0]:
>                   print x
> 
>  /var/www/html/angrynates.com/cart/display.py 
> <http://angrynates.com/cart/display.py>
>    98     raise
>    99   cursor.close()
>   100   bottom()
>   101
>   102 display()
> display = <function display>
>  /var/www/html/angrynates.com/cart/display.py 
> <http://angrynates.com/cart/display.py> in display()
>    50 #                newCol = list(colValue[0])
>    51 #                print newCol[0:20]
>    52                 for x in colValue[0]:
>    53                   print x
>    54                 print 'XXX'
> x undefined, colValue = (datetime.date(2009, 10, 22),)
> 
> TypeError: iteration over non-sequence
>       args = ('iteration over non-sequence',)
> 
That tells me that, in this case, colValue[0] is an instance of
datetime, not Set.



More information about the Python-list mailing list