Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'syntax': 0.04; 'mrab': 0.05; 'true,': 0.05; 'modify': 0.07; 'odd': 0.07; 'python3': 0.07; 'versions.': 0.07; 'happen,': 0.09; 'iterate': 0.09; 'lawrence': 0.09; 'snippet': 0.09; 'subject:parsing': 0.09; 'python': 0.11; 'jan': 0.12; 'posted': 0.15; '3.1.3': 0.16; 'inclined': 0.16; 'objects.': 0.16; 'such,': 0.16; 'syntaxerror:': 0.16; 'url:peps': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'seems': 0.21; '>>>': 0.22; 'code,': 0.22; 'to:name:python-list@python.org': 0.22; 'replace': 0.24; 'url:dev': 0.24; "i've": 0.25; '(see': 0.26; 'least': 0.26; '2010,': 0.27; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'chris': 0.29; 'related': 0.29; 'dec': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; '>>>>': 0.31; 'exceptions': 0.31; 'file': 0.32; 'received:209.85.212': 0.32; 'url:python': 0.33; 'cases': 0.33; 'skip:d 20': 0.34; "i'd": 0.34; 'subject:from': 0.34; 'could': 0.34; 'received:209.85': 0.35; 'something': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'yield': 0.36; 'url:org': 0.36; 'received:209': 0.37; 'nov': 0.38; 'handle': 0.38; 'needed': 0.38; 'to:addr:python-list': 0.38; 'issue': 0.38; 'pm,': 0.38; 'supporting': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'upgrading': 0.60; 'most': 0.60; 'introduced': 0.61; 'simple': 0.61; 'here:': 0.62; 'more': 0.64; 'here': 0.66; 'believe': 0.68; 'production': 0.68; 'invalid': 0.68; 'safe': 0.72; '2015': 0.84; 'upgrade,': 0.84; 'choice.': 0.93 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=jq9oYOh5o0nNst69meBcluB7l0IekBP+qcPMFYI+zAk=; b=HymfrSUxKepGecKwh0EyYu6wXaJ74u3DhbYZIwbvLSob4llGf+nh3pOwxG8PwyBYmK Ce6+vDCEqVm5MLOtKYbifRFfMZYOsr2zzQEptt+GN7A1vJ2YSqF2eYWX6B6CM91Qr2D5 MkXYc5D6RHkQ9WWfqtxb5BcSpWBsssk+qEPYTFqf8MHXeDtU2nJjKQ+LBGcoYKwy+shw roLKmbucKuFbszn7O1uFmm+KeCaJjwpvehRZAZNCATxwLWCtXIWOx/cvhrs47K64lWSK KmzDqAIndhY4BZyHgTa8DDfILQL8bWlT0BXjdtbi3DVkt5MZerk71VbSE9xAs8XqNuFu LD7Q== X-Gm-Message-State: ALoCoQmc+xqgitNiiofaotfYCxFM4r5bY5k7NifI5j9RL8d2gghECnjQt+IAEoxasDKhIdfHAHCc X-Received: by 10.180.207.66 with SMTP id lu2mr5578320wic.13.1422570628244; Thu, 29 Jan 2015 14:30:28 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: From: Chris Kaynor Date: Thu, 29 Jan 2015 14:30:08 -0800 Subject: Re: parsing tree from excel sheet To: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 64 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1422570630 news.xs4all.nl 2936 [2001:888:2000:d::a6]:39865 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:84850 On Thu, Jan 29, 2015 at 1:59 PM, Mark Lawrence wrote: > On 29/01/2015 21:32, alb wrote: >> >> Hi MRAB, >> >> MRAB wrote: >> [] >>>>> >>>>> SyntaxError: invalid syntax >>>>> debian@debian:example$ python3 export_latex.py doctree.csv >>>>> File "export_latex.py", line 36 >>>>> yield from child.show2() >>>>> ^ >>>>> SyntaxError: invalid syntax >>>> >>>> >>>> and I've tried with both python and python3 (see below versions). >>>> >>>> debian@debian:example$ python >>>> Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40) >>>> [GCC 4.4.5] on linux2 >>>> Type "help", "copyright", "credits" or "license" for more information. >>>>>>> >>>>>>> >>>> debian@debian:example$ python3 >>>> Python 3.1.3 (r313:86834, Nov 28 2010, 11:28:10) >>>> [GCC 4.4.5] on linux2 >>>> Type "help", "copyright", "credits" or "license" for more information. >>>>>>> >>>>>>> >>>> >>>> Is it an issue related to my installation? Shall I upgrade and/or >>>> downgrade? >>>> >>> "yield from" was introduced in Python 3.3. >>> >> >> Ok, that either means I need to upgrade to 3.3 or need to modify the >> snippet to a suitable syntax that would work with other versions. >> >> Considering that upgrading is something that I'm not keen to do on my >> production system I believe I've only have one available choice. >> >> It seems I could use the generator and iterate with .next() in python >> 2.6, at least from what I found here: >> >> http://stackoverflow.com/questions/1756096/understanding-generators-in-python >> >> Al >> > > I'd be inclined to upgrade, see here > https://www.python.org/dev/peps/pep-0380/#formal-semantics for why :) While that is true, most of that code is needed to handle the odd corner cases and exceptions that could happen, as well as supporting generator.throw and generator.send, while also ensuring proper and quick clean-up of the objects. >From what I could see at a quick glance, none of that is really needed in the simple case in the posted code, and as such, it is LIKELY safe to just replace "yield from ..." with "for item in ...: yield item". Chris