On 14 October 2010 20:29, David Hutto <smokefl...@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(),

Using eval is a big security risk and is generally not recommended for
any production code. What do you think eval() return for your string?
A tuple of ints which for your use case serves the same purpose as
using the list comprehension.

If you really want (you really don't) to use eval() then at least use
the safe one from the ast mode.

>>> from ast import literal_eval
>>> literal_eval(u'1,2,3,4')
(1, 2, 3, 4)
>>> eval(u'1,2,3,4')
(1, 2, 3, 4)

As you can see for your use case both return a tuple of ints.

Greets
Sander
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to