[Tutor] Converting from unicode to nonstring
smokefloat at gmail.com
Fri Oct 15 12:26:48 CEST 2010
Ok, Let me restate and hopefully further clarify.
1. I have a field for a wxpython app using matplotlib to display
2. I have a sqlite3 db which I'm retrieving information from
3. The sqlitle data is returned as unicode: u'field'
4. The portion of the matplotlib code is filled in, in a for x in y:
5. in plot(self.plot), self.plot is the variable I'm using from the unicoded db
field comes in from sqlite as u'[1,2,3,4]', which places a string in quotes in
that variables place:
6. the plot(eval(self.plot)), changes the variable from the u'[1,2,3,4]'
to just [1,2,3,4]
7 As stated somewhere above, the float error has nothing to do with
the probel, only the fact that it was used as if I had placed ''
around the necessary data from the db field.
8. If anyone has a way better than eval to convert the u'field' when
replacing a variable so that
self.plot = [1,2,3,4]
self.plot = u'[1,2,3,4]'
Let me know, meanwhile I'll be reviewing the replies more thoroughly,
now that I've had a nap.
More information about the Tutor