En Wed, 19 Dec 2007 19:23:36 -0300, John Machin <[EMAIL PROTECTED]> escribió:
> On Dec 20, 9:10 am, Larry Bates <[EMAIL PROTECTED]> wrote: >> Stef Mientki wrote: >> >> > I need to translate the following string >> > a = '(0, 0, 0, 255), (192, 192, 192, 255), True, 8' >> >> > into the following list or tuple >> > b = [(0, 0, 0, 255), (192, 192, 192, 255), True, 8 ] >> >> > Is there a simple way to to this. > > In particular Paul Maguire recently pointed to a safe evaluator that > was restricted (IIRC) to something like lists/dicts/etc of ints/floats/ > string/etc constants -- looks like just what you need. There is also a Cookbook recipe for a safe_eval function at http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/364469 > Does anyone know of a newsreader that can automatically killfile > people who suggest eval without any warnings at all? Or should we let > Darwinian selection take its effect? Doesn't work, Darwininan selection would act on the unfortunate people asking, not on who careless answers "use eval" :( -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list