Re: Question about ast.literal_eval

Discussion in 'Python' started by Chris Angelico, May 20, 2013.

  1. On Mon, May 20, 2013 at 5:55 PM, Carlos Nepomuceno
    <> wrote:
    > I understand your motivation but I don't know what protection ast.literal_eval() is offering that eval() doesn't.


    eval will *execute code*, while literal_eval will not. That's the
    protection. With ast.literal_eval, all that can happen is that it
    produces a single result value. In this case, unfortunately, that's
    insufficient; a comparison needs to be done, ergo it's not an entire
    literal. But something else in the ast module may be able to serve, or
    maybe literal_eval can do the bulk of the work.

    ChrisA
     
    Chris Angelico, May 20, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Frank Millman

    Question about ast.literal_eval

    Frank Millman, May 20, 2013, in forum: Python
    Replies:
    2
    Views:
    160
    Frank Millman
    May 21, 2013
  2. Carlos Nepomuceno

    RE: Question about ast.literal_eval

    Carlos Nepomuceno, May 20, 2013, in forum: Python
    Replies:
    0
    Views:
    99
    Carlos Nepomuceno
    May 20, 2013
  3. Chris Angelico

    Re: Question about ast.literal_eval

    Chris Angelico, May 20, 2013, in forum: Python
    Replies:
    0
    Views:
    108
    Chris Angelico
    May 20, 2013
  4. Frank Millman

    Re: Question about ast.literal_eval

    Frank Millman, May 20, 2013, in forum: Python
    Replies:
    0
    Views:
    107
    Frank Millman
    May 20, 2013
  5. Chris Angelico

    Re: Question about ast.literal_eval

    Chris Angelico, May 20, 2013, in forum: Python
    Replies:
    0
    Views:
    96
    Chris Angelico
    May 20, 2013
Loading...

Share This Page