Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > RE: top-level loops

Reply
Thread Tools

RE: top-level loops

 
 
Michael Chermside
Guest
Posts: n/a
 
      10-08-2003
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


 
Reply With Quote
 
 
 
 
Cameron Laird
Guest
Posts: n/a
 
      10-08-2003
In article <mailman.1065649095.3003.python->,
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple For Loops? pinod01@sympatico.ca VHDL 1 02-22-2006 03:10 PM
Etherchannel disabled = spanning tree loops... traust Cisco 0 02-21-2006 05:34 PM
Loops with loops using html-template Me Perl Misc 2 01-12-2006 05:07 PM
Perl loops should use break, not last Jeremy Morton Perl 1 01-30-2005 10:50 PM
to many FOR loops? eismaus4 VHDL 1 04-27-2004 02:54 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57