improper position of continue?
Cezar Ionescu
ionescu at pik-potsdam.de
Wed Aug 2 10:41:40 EDT 2000
[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.
More information about the Python-list
mailing list