[Tutor] Converting from unicode to nonstring
smokefloat at gmail.com
Thu Oct 14 21:31:39 CEST 2010
On Thu, Oct 14, 2010 at 3:24 PM, Adam Bark <adam.jtm30 at gmail.com> wrote:
> On 14/10/10 20:21, David Hutto wrote:
>> On Thu, Oct 14, 2010 at 2:58 PM, Adam Bark<adam.jtm30 at gmail.com> wrote:
>>>> Actually, I needed it to be converted to something without a string
>>>> attached to it. See a post above, and it was fixed by eval(),
>>>> Thanks though. And I'm sure at some point this morning in a moment of
>>>> frustration rather than logic, I tried your approach.
>>> What do you mean by "without a string attached to it"?
>>> Also using eval could be dangerous unless you're sure the stuff coming
>>> of your dbase is safe.
>> Read the above posts and it should be explanation enough.
> I did read them and it's really not clear.
I needed to have:
self.lines = self.newplot.plot(self.plot)
from the data I brought in I got the following when the variable
above(self.plot) was inserted:
self.lines = self.newplot.plot(u'plot')
So by applying eval:
self.lines = self.newplot.plot(eval(self.plot))
It then inserted the following when the variable self.plot was used:
self.lines = self.newplot.plot(eval(plot)
no u'stringhere' in the second version with eval around the variable.
I hope that makes it clearer. Otherwise I might have to let you borrow
my Windex to clean the screen.
More information about the Tutor