Steven Bethard steven.bethard at
Tue Jul 19 00:17:37 CEST 2005

rbt wrote:
> Steven Bethard wrote:
>>Download the goto module:
>>And you can use goto to your heart's content. And to the horror of all 
>>your friends/coworkers. ;)
> Shouldn't that be "to the horror of all your goto-snob friends."
> IMO, most of the people who deride goto do so because they heard or read
> where someone else did. 
> Many of the world's most profitable software companies (MS for example)
> have thousands of goto statements in their code... oh the horror of it
> all. Why aren't these enlightened-by-the-gods know-it-alls as profitable
> as these obviously ignorant companies?

Perhaps I should reiterate: ;)  Oh, and ;)

The CPython source code is filled with gotos -- with a rough grep count, 
I found over 2000.  And, while I wouldn't care to inspect them all, I'd 
guess that they're mostly quite appropriate.  A lot of them look like 
"goto fail", "goto finally", etc. and are used to handle error 
conditions.  Heck, the patch I wrote to add key= arguments to min() and 
max() in Python 2.5 uses goto for exactly this purpose.

That said, I don't think my joke was really that inaccurate -- I have 
yet to see a good use case for gotos in Python.  Why use gotos when you 
have an efficient exception handling mechanism?


More information about the Python-list mailing list