improper position of continue?
Robin Becker
robin at jessikat.fsnet.co.uk
Wed Aug 2 11:48:40 EDT 2000
In article <39883324.2936A58D at pik-potsdam.de>, Cezar Ionescu
<ionescu at pik-potsdam.de> writes
interestingly break is fine
>>> while 1:
... try:
... print 'hello'
... break
... except:
... print 'bongo'
...
hello
>>>
I guess it's just the loop start address which is lacking the loop exit
is there :)
>[Rob]:
>
>> >>> while 1:
>> ... try:
>> ... continue
>> ... finally:
>> ... pass
>> ...
>> SyntaxError: 'continue' not properly in loop (line 3)
>> >>>
>>
>> Why?
>
>Quoting from the language reference manual:
>
> continue may only occur syntactically nested in a for or while loop,
> but not nested in a function or class definition or try statement
> within that loop.[footnote]It continues with the next cycle of the
>nearest
> enclosing loop.
>
>This explains the fact that you get a sintax error. As for why, the
>footnote says:
>
> The restriction
> on occurring in the try clause is implementer's laziness and
> will eventually be lifted.
>
>Best,
>Cezar.
--
Robin Becker
More information about the Python-list
mailing list