goto statement

Reinhold Birkenfeld reinhold-birkenfeld-nospam at wolke7.net
Fri Apr 22 09:47:44 EDT 2005


Grant Edwards wrote:
> On 2005-04-21, Sergei Organov <osv at javad.ru> wrote:
> 
>>>>>> Well, I'm writing for embedded realtime systems in C/C++ and
>>>>>> have never encountered a single need to use goto.
>>>>> 
>>>>> I have encountered situations in C programs where the best
>>>>> thing to use was a goto.  Those situations have always been
>>>>> handled beutifully by a "raise" in Python.
>>>>
>>>> setjmp/longjump?
>>> 
>>> I've always found setjmp/longjmp much more confusing and hard
>>> to maintain than a simple goto.  It also requires library
>>> support that goto doesn't.
>>
>> Agreed. The 'goto error' idiom is in fact the only goto usage
>> I do agree with provided there is no support for exceptions,
>> but that's not applicable to Python anyway.
> 
> Exactly.  I've been writing C code for 20+ years, and the only
> problems where I found goto to be a good solution are the ones
> where exceptions are even better solutions in Python.  I've
> never found myself wishing for a goto when writing Python code.

The Python C source code is full of such gotos, it must be good
practise...

Reinhold



More information about the Python-list mailing list