Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin1!goblin.stu.neva.ru!news.astraweb.com!border5.a.newsrouter.astraweb.com!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.013 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'pop': 0.05; 'subject:Question': 0.07; 'subject:skip:a 10': 0.09; 'cc:addr :python-list': 0.11; 'python': 0.11; 'suggest': 0.14; 'ast': 0.16; 'bracket,': 0.16; 'brackets.': 0.16; 'think.': 0.16; 'wrote:': 0.18; 'stack': 0.19; 'cc:addr:python.org': 0.22; 'creating': 0.23; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '>': 0.26; 'push': 0.26; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; 'something': 0.35; 'received:google.com': 0.35; 'level': 0.37; 'issue': 0.38; "you're": 0.61; 'address': 0.63; 'results': 0.69; 'walking': 0.91; 'imagine': 0.93; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=spk9UYxvNWpsrSM5eML3Uyohpcg2ct802wBQRAEJVm0=; b=wB8uqvzGrvYuphbA5F3MRCgmPv/bVDaPP58VKgAT/fYTiNptw/dG3QAXR6x+lyPN2X SPyCueTNisajz5Yd9OgSu5sfscq60MkNBb9JH7chO218a/mgdsXxRklq4CmAX5dJmSI2 9iChGPmdTgVeJk0btXpsv/S1Ei04vP4N+3d7zEAnoMeRXXFfqxq6oJnlOqFQQwLUy/IU UZtEOwGKw3ggt4icLRfrC98UeoRmwn5LFwSD1g5n38lTmpJb7xrmQMI1098azmzsOFSr k9ixSq1d0dII6IhubHowknhI0AIXvKADcENakRPUPVAEeGkErghf65KJXGT80BsQivbH NUlQ== MIME-Version: 1.0 X-Received: by 10.224.192.6 with SMTP id do6mr1508817qab.82.1369124596494; Tue, 21 May 2013 01:23:16 -0700 (PDT) In-Reply-To: References: <519a4b6a$0$29997$c3e8da3$5496439d@news.astraweb.com> <519b2096$0$6574$c3e8da3$5496439d@news.astraweb.com> Date: Tue, 21 May 2013 09:23:16 +0100 Subject: Re: Question about ast.literal_eval From: =?ISO-8859-1?Q?F=E1bio_Santos?= To: Frank Millman Content-Type: multipart/alternative; boundary=20cf300fb1cb3a542c04dd3629ec Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1369124922 news.xs4all.nl 16003 [2001:888:2000:d::a6]:43041 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:45653 --20cf300fb1cb3a542c04dd3629ec Content-Type: text/plain; charset=ISO-8859-1 On 21 May 2013 09:10, "Frank Millman" wrote: > It doesn't address the issue of brackets. I imagine that the answer is something like - > > maintain a stack of results > for each left bracket, push a level > for each right bracket, pop the result > > or something ... > Time for me to suggest pyparsing or PLY. You're better off creating your own AST and walking it to produce python or SQL than reinventing the wheel, I think. --20cf300fb1cb3a542c04dd3629ec Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable


On 21 May 2013 09:10, "Frank Millman" <frank@chagford.com> wrote:
> It doesn't address the issue of brackets. I imagine that the answe= r is something like -
>
> =A0 maintain a stack of results
> =A0 for each left bracket, push a level
> =A0 for each right bracket, pop the result
>
> or something ...
>

Time for me to suggest pyparsing or PLY. You're better o= ff creating your own AST and walking it to produce python or SQL than reinv= enting the wheel, I think.

--20cf300fb1cb3a542c04dd3629ec--