Python equivalent for perl's "next"-statement?

Helmut Jarausch jarausch at skynet.be
Wed Oct 22 12:44:30 EDT 2003


Gerhard Häring wrote:
> Eric Wichterich wrote:
> 
>> Hello Pythonistas,
>>
>> does anyone know an equivalent python statement for perl's 
>> "next"-statement?
>> (Perl's "next" skips a loop cycle and continues with the next loop 
>> cycle - it does not abort the whole loop).
> 
> 
> It's the 'continue' statement.
> 

Unfortunately, that's not the full truth.
In Perl the 'next' and 'last' instructions may refer
to a label of an (outer) loop and thus perform the action
for that specific outer loop.
Such possibilities are sadly missing in Python.
In the case of 'last' one can raise an exception,
while for 'next' I am not aware of an elegant solution.


-- 
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany






More information about the Python-list mailing list