[Tutor] Converting from unicode to nonstring

David Hutto smokefloat at gmail.com
Thu Oct 14 16:14:54 CEST 2010

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.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]

I get the error:

ValueError: invalid literal for float(): 1,2,3,4

So my question is, how do I convert the unicode '' to a plain nonstring insert?


More information about the Tutor mailing list