473,406 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

top-level loops

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)
Jul 18 '05 #1
2 1658
Stefan wrote:
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

Jul 18 '05 #2
Stefan wrote:
#!/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.

--
192. If a son of a paramour or a prostitute say to his adoptive father
or mother: "You are not my father, or my mother," his tongue shall be cut
off.
-- 1780 BC, Hammurabi, Code of Law
--
Asperger Syndroom - een persoonlijke benadering:
http://people.nl.linux.org/~gerrit/
Kom in verzet tegen dit kabinet:
http://www.sp.nl/

Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

145
by: David MacQuigg | last post by:
Playing with Prothon today, I am fascinated by the idea of eliminating classes in Python. I'm trying to figure out what fundamental benefit there is to having classes. Is all this complexity...
0
by: Ataru Morooka | last post by:
Hello, I am renewing a website using CSS and I have some problems with IE6. Following this link: http://www.ansv.it/templates/Template_Index_IT.dwt.asp you may notice that the container area has...
19
by: Mason A. Clark | last post by:
How was I to know that "top" means "top" in MSIE6 ?? I was testing <a name="top"></a> at the top of the page with <a href="#top>go to top</a> at the bottom of the page. It always worked in...
6
by: Mason A. Clark | last post by:
LAST WORD(s): 1. MSIE6 and Firefox will go to the top of the page on command <a href="#top">go upsy</a> even if there is NO name="top" or id="top" They know what a "top" is :-) Opera...
0
by: BACON | last post by:
I'm just starting the process of reorganising my modest little website and cleaning up all the HTML, and the logical place to begin was with the homepage. I made a simple little ASP.NET control...
5
by: BACON | last post by:
I'm just starting the process of reorganising my modest little website and cleaning up all the HTML, and the logical place to begin was with the homepage. I made a simple little ASP.NET control...
23
by: Antoon Pardon | last post by:
I know this PEP is rejected. However I have a problem that would benefit from having extreme values and the sample implementation that is given in the PEP is unsatifactory for my purpose. I had...
2
by: levilarsen | last post by:
Hi, thanks for reading this post. I have a web page that displays fine in IE but in Firefox and Safari there is a space at the top of the web page. It is as if the whole page is pushed down, like...
6
by: Samuel Rhodes | last post by:
Hi I am trying to write a code snippet that would display a '?' sign on the top left of a control. I do not want to hard code the positioning of the DIV which will contain that '?'. Is it...
2
by: noe1818 via AccessMonster.com | last post by:
Can anyone tell my why this isn't working? Me!.top=(1440/2.54)*16.78-*0.4) I want it so that for every 1 change in , a rectangular box moves 0.4 units closer to the top. The 1440/2.54...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.