Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.04; 'pop': 0.05; 'subject:Question': 0.07; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:skip:a 10': 0.09; 'python': 0.11; 'suggest': 0.14; 'ast': 0.16; 'bracket,': 0.16; 'brackets.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'think.': 0.16; 'wrote:': 0.18; 'stack': 0.19; 'creating': 0.23; 'header:User-Agent:1': 0.23; 'url:moin': 0.24; 'push': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; 'url:wiki': 0.31; 'url:python': 0.33; 'something': 0.35; 'url:org': 0.36; 'level': 0.37; 'to:addr:python-list': 0.38; 'issue': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'read': 0.60; "you're": 0.61; 'address': 0.63; 'pick': 0.64; 'charset:windows-1252': 0.65; 'results': 0.69; 'received:89': 0.85; 'walking': 0.91; 'imagine': 0.93; '2013': 0.98 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: Question about ast.literal_eval Date: Tue, 21 May 2013 10:00:48 +0100 References: <519a4b6a$0$29997$c3e8da3$5496439d@news.astraweb.com> <519b2096$0$6574$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: host-89-240-174-199.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 In-Reply-To: X-Antivirus: avast! (VPS 130520-1, 20/05/2013), Outbound message X-Antivirus-Status: Clean 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: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1369126836 news.xs4all.nl 15993 [2001:888:2000:d::a6]:55170 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:45655 On 21/05/2013 09:23, Fábio Santos wrote: > > 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. > Or pick one from this lot http://nedbatchelder.com/text/python-parsers.html -- If you're using GoogleCrap™ please read this http://wiki.python.org/moin/GoogleGroupsPython. Mark Lawrence