Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • 7
    If you have to terminate calculation somewhere in a deeply nested statement and go to some common continuation code, this particular path of execution can very probably be factored out as a function, with return in place of goto. Commented Mar 5, 2013 at 0:40
  • 3
    @9000 I was about to comment exactly the same thing ... Keep try: blocks to 1 or 2 lines please, never try: # Do lots of stuff. Commented Mar 5, 2013 at 3:57
  • 4
    @9000, in some cases, sure. But then you lose access to local variables, and you move your code yet-another-place, when the process is a coherent, linear process. Commented Mar 14, 2013 at 5:45
  • 5
    @gahooa: I used to think like you. It was a sign of poor structure of my code. When I put more thought in it, I noticed that local contexts can be untangled and the whole mess made into short functions with few parameters, few lines of code, and very precise meaning. I never looked back. Commented Mar 14, 2013 at 5:52