top-level loops

S

Stefan

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?


#!/usr/bin/env python

import string, sys, os

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

# filePrefix = '%d_%d' % (i,j)
# filePrefix = sys.argv[1]
print 'Run getQ'
os.system('~/Programs/KineticEnsemble/GetQMod/getq.exe
/home/reza/Proteins/2ci2/2CI2.contacts ' + filePrefix + '/md\crd 1 100
1.2 ' + filePrefix + '/q.out')

print 'Analyze getQ results'
file=open(filePrefix + '/q.out','r')

fold=0.
ufold=0.
isOpen=1
#numRuns=0

for line in file.readlines():
if line != '#NEWFILE\n':
# if open:
# numRuns += 1
if string.atof(line[:-1]) < 0.15 and isOpen:
isOpen = 0
ufold+=1.
elif string.atof(line[:-1]) > 0.85 and isOpen:
isOpen = 0
fold+=1.
else:
# print numRuns
# numRuns = 0
isOpen = 1

file.close()

print filePrefix
print '\tpFold: %f' % ( fold/(ufold+fold))
print '\tfold: %d ufold: %d' % (fold,ufold)
 
K

Karl Scalet

Stefan said:
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?

either follow Camerons suggestion :) or:


for x in (1,2,3):
for y in (4,5,6):
print 'Run it'

change to:

if """
for x in (1,2,3):
for y in (4,5,6):
""":
print 'Run it'

But very likely there are other and probably better solutions.

Karl
 
G

Gerrit Holl

Stefan said:
#!/usr/bin/env python

import string, sys, os

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

# filePrefix = '%d_%d' % (i,j)
# filePrefix = sys.argv[1]

You can do:
if True:
if True:
# code here

Gerrit.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top