Eval (was Re: Question about using python as a scripting language)

skip at pobox.com skip at pobox.com
Wed Aug 9 12:03:52 EDT 2006


    Brendon> I could do that, or I could do something like the re.* trick
    Brendon> mentioned by another poster. But, doesn't it offend anyone else
    Brendon> that the only clean way to access functionality that's already
    Brendon> in Python is to write long complicated Python code? Python
    Brendon> already knows how to extract a list object from a string; why
    Brendon> should I have to rewrite that?

Doesn't bother me at all.  One, it's not actually Python code, it's
JavaScript.  It's just serendipity that the table can be parsed as a Python
list.  Two, there's nothing to prevent the authors from changing the
formatting in an incompatible way in the future.  Three, it's completely
untrusted input and shouldn't be fed to eval().  Four, it's not actually
complicated code (using the csv module would probably be simpler).  Had the
NASD had a requirement that their HTML pages be easily assimilated into
Python I might agree with you.  I suspect that wasn't high up on their
priority list though.  Five, you have to stop thinking of it a "list
object".  It's just a string of bytes which happens at this point in time to
intersect with the definition of a Python list.  You're trying to wish it
was something that it's not.

Skip



More information about the Python-list mailing list