Re: Question about ast.literal_eval

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

  1. On Mon, May 20, 2013 at 11:26 PM, Frank Millman <> wrote:
    > 0 - for the first entry in the list, the word 'check' (a placeholder - it is
    > discarded at evaluation time), for any subsequent entries the word 'and' or
    > 'or'.
    >
    > 1 - left bracket - either '(' or ''.
    >
    > 5 - right bracket - either ')' or ''.


    I think what you have is safe, but extremely complicated to work with.
    Six separate pieces, and things have to be in the right slots... I
    think you've spent too many "complexity points" on the above three
    components, and you're getting too little return for them. What
    happens if the nesting is mucked up? Could get verrry messy to check.

    Combining multiple conditions with a mixture of ands and ors is a
    nightmare to try to explain (unless you just point to the Python docs,
    which IMO costs you even more complexity points); the only safe option
    is to parenthesize everything. The system I pushed for at work (which
    was finally approved and implemented a few months ago) is more or less
    this: conditions are grouped together into blocks; for each group, you
    can choose whether it's "all" or "any" (aka and/or), and you choose
    whether the overall result is all-groups or any-group. That still
    costs a few complexity points (and, btw, our *actual* implementation
    is a bit more complicated than that, but I think we could cut it down
    to what I just described here without loss of functionality), but it
    gives the bulk of what people will actually want without the
    complexities of point-and-click code.

    The downside of that sort of system is that it requires a two-level
    tree. On the flip side, that's often how people will be thinking about
    their conditions anyway (eg using a pair of conditions ">" and "<" to
    implement a range check - conceptually it's a single check), so that
    won't cost too much.

    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:
    125
    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:
    70
    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:
    86
    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:
    80
    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:
    74
    Chris Angelico
    May 20, 2013
Loading...

Share This Page