Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #84850

Re: parsing tree from excel sheet

References (1 earlier) <mailman.18217.1422454096.18130.python-list@python.org> <civleiF21boU1@mid.individual.net> <mailman.18282.1422566221.18130.python-list@python.org> <civn75F21boU3@mid.individual.net> <maeagt$1of$1@ger.gmane.org>
From Chris Kaynor <ckaynor@zindagigames.com>
Date 2015-01-29 14:30 -0800
Subject Re: parsing tree from excel sheet
Newsgroups comp.lang.python
Message-ID <mailman.18284.1422570630.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, Jan 29, 2015 at 1:59 PM, Mark Lawrence <breamoreboy@yahoo.co.uk> wrote:
> On 29/01/2015 21:32, alb wrote:
>>
>> Hi MRAB,
>>
>> MRAB <python@mrabarnett.plus.com> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

parsing tree from excel sheet al.basili@gmail.com (alb) - 2015-01-28 10:12 +0000
  Re: parsing tree from excel sheet Peter Otten <__peter__@web.de> - 2015-01-28 15:08 +0100
    Re: parsing tree from excel sheet al.basili@gmail.com (alb) - 2015-01-28 14:27 +0000
    Re: parsing tree from excel sheet al.basili@gmail.com (alb) - 2015-01-29 21:02 +0000
      Re: parsing tree from excel sheet MRAB <python@mrabarnett.plus.com> - 2015-01-29 21:16 +0000
        Re: parsing tree from excel sheet al.basili@gmail.com (alb) - 2015-01-29 21:32 +0000
          Re: parsing tree from excel sheet Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-01-29 21:59 +0000
          Re: parsing tree from excel sheet Chris Kaynor <ckaynor@zindagigames.com> - 2015-01-29 14:30 -0800
          Re: parsing tree from excel sheet Chris Angelico <rosuav@gmail.com> - 2015-01-30 10:46 +1100
    Re: parsing tree from excel sheet al.basili@gmail.com (alb) - 2015-01-30 15:05 +0000
      Re: parsing tree from excel sheet Peter Otten <__peter__@web.de> - 2015-01-30 18:11 +0100
        Re: parsing tree from excel sheet al.basili@gmail.com (alb) - 2015-01-31 22:45 +0000
          Re: parsing tree from excel sheet Peter Otten <__peter__@web.de> - 2015-02-01 11:11 +0100
      Re: parsing tree from excel sheet Peter Otten <__peter__@web.de> - 2015-01-30 18:24 +0100
      Re: parsing tree from excel sheet Peter Otten <__peter__@web.de> - 2015-01-31 10:07 +0100
      Re: parsing tree from excel sheet Peter Otten <__peter__@web.de> - 2015-01-31 10:07 +0100
  Re: parsing tree from excel sheet Tim Chase <python.list@tim.thechases.com> - 2015-01-28 08:13 -0600
    Re: parsing tree from excel sheet al.basili@gmail.com (alb) - 2015-01-29 21:22 +0000

csiph-web