RE: top-level loops

Discussion in 'Python' started by Michael Chermside, Oct 8, 2003.

  1. Stefan writes:
    > I am writing a program (code included) and I would like to comment out
    > the two top-level loops and run the code that is under it regularly,
    > however, because the following code is not indented properly the
    > interpreter chokes. Is there a way around this?


    Well first of all, I prefer to use an editor which will allow me
    to indent or dedent entire blocks of code at a time. There are lots
    of others, but Idle (which almost certainly came with your copy of
    Python) is one... select the block then use tab or shift-tab.

    Also, in your case there's another quick work-around:


    #for i in range(0,3):
    # for j in range(0,3):
    for i in range(0,1):
    for j in range(0,1):

    ... rest of program goes here...


    Notice how I left in the for loops, but made sure that each
    occurred only once.

    -- Michael Chermside
     
    Michael Chermside, Oct 8, 2003
    #1
    1. Advertising

  2. In article <>,
    Michael Chermside <> wrote:
    >Stefan writes:
    >> I am writing a program (code included) and I would like to comment out
    >> the two top-level loops and run the code that is under it regularly,
    >> however, because the following code is not indented properly the
    >> interpreter chokes. Is there a way around this?

    >
    >Well first of all, I prefer to use an editor which will allow me
    >to indent or dedent entire blocks of code at a time. There are lots
    >of others, but Idle (which almost certainly came with your copy of
    >Python) is one... select the block then use tab or shift-tab.
    >
    >Also, in your case there's another quick work-around:
    >
    >
    > #for i in range(0,3):
    > # for j in range(0,3):
    > for i in range(0,1):
    > for j in range(0,1):
    >
    > ... rest of program goes here...
    >
    >
    >Notice how I left in the for loops, but made sure that each
    >occurred only once.
    >
    >-- Michael Chermside
    >
    >


    Are you the kind of fellow who writes a lot of
    if 1 or complicated_function():
    other_stuff();
    too, to the same end? I know *I* am ...

    Stefan, if this really is a problem for you, it
    suggests to me that it might be time for you to
    define the body of the loop as an explicit
    function, which you unit-test separately.
    --

    Cameron Laird <>
    Business: http://www.Phaseit.net
     
    Cameron Laird, Oct 8, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Frederic HOUDE
    Replies:
    4
    Views:
    629
    Frederic HOUDE
    Aug 31, 2004
  2. Stefan

    top-level loops

    Stefan, Oct 8, 2003, in forum: Python
    Replies:
    2
    Views:
    300
    Gerrit Holl
    Oct 9, 2003
  3. pabbu
    Replies:
    8
    Views:
    770
    Marc Boyer
    Nov 7, 2005
  4. Cuthbert
    Replies:
    8
    Views:
    463
    Ancient_Hacker
    Sep 13, 2006
  5. Me
    Replies:
    2
    Views:
    264
Loading...

Share This Page