[Tutor] Converting from unicode to nonstring

David Hutto smokefloat at gmail.com
Thu Oct 14 19:43:46 CEST 2010


On Thu, Oct 14, 2010 at 11:16 AM, David Hutto <smokefloat at gmail.com> wrote:
> On Thu, Oct 14, 2010 at 10:14 AM, David Hutto <smokefloat at gmail.com> wrote:
>> Hey Buddy Pals,
>>
>> I receive the following output from a sqlite db
>>
>> (u'graph1', u'Line', u'222', u'BLUE', u'1,2,3,4', u'True', u'0,5,0,10')
>>
>> Which is a tuple of unicode strings. From this I
>> need to place portions of the tuple into other fields,
>> but not as unicode strings, but literals no ''.
>>
>> For example if I have the following line:
>>
>> self.lines = self.newplot.plot([1,2,3,4])
>>
>> And I use the following to replace [1,2,3,4] with
>> self.plot from line 13 in belows iteration:
>>
>>                self.orderbygname = self.cur.execute('''select * from %s order by
>> graphname''' % ('graphs'))
>>                self.orderlist = []
>>                for name in self.orderbygname:
>>                        self.orderlist.append(name)
>>                self.fig = Figure()
>>                for line in self.orderlist:
>>                        print line
>>                        #print line[0],' and ', line[1]
>>                        self.graphname = line[0]
>>                        self.graphtype = line[1]
>>                        self.position = line[2]
>>                        self.bgcolor = line[3]
>>                        self.plot = line[4]
>>                        self.grid = line[5]
>>                        self.x_y_axis_range = line[6]
>>


Fixed with:

self.lines = self.newplot.plot(eval(self.plot))


More information about the Tutor mailing list