[BangPypers] How should I do it?

Anand Balachandran Pillai abpillai at gmail.com
Fri Jan 15 11:37:38 CET 2010


On Fri, Jan 15, 2010 at 4:03 PM, Noufal Ibrahim <noufal at gmail.com> wrote:

> On Fri, Jan 15, 2010 at 4:00 PM, Baishampayan Ghose <b.ghose at gmail.com
> >wrote:
>
> > > It is a clever hack, taking advantage of the nature of the data. But
> > > it is far more faster than the other approaches posted here.
> >
> > I thought eval was evil :)
> >
>
> Given that the OPs data is fixed, eval is okay. :)
>
> Otherwise, it could be evil or unreliable (eg. => inside some of the data
> strings etc.)
>

 My sentiments are the same. As long as you are sure of
 the safety of your data such as absence of %s etc which
 could cause security issues, eval is safe. It can often be
 used for quick short-cuts such as the one above.

 I started off with a regular expression solution first, but
 after I observed that the pattern fits a recursive dict,
 changed tack.

 Btw "eval" is spelled e-v-a-l, not e-v-i-l :)


>
> --
> ~noufal
> http://nibrahim.net.in
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>



-- 
--Anand


More information about the BangPypers mailing list