By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,941 Members | 1,753 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,941 IT Pros & Developers. It's quick & easy.

Help with Break Command

P: 13
What in the world is going on here? I cannot get my "break" statement to work.

When I run this class, I get the following output:

>>>
---BREAK--- 0
WHY WON'T YOU BREAK
count = 0
Traceback (most recent call last):
File "C:\Documents and Settings\M01091\Desktop\New Folder\tester.py", line 72, in ?
TransformerRecords1 = TransformerData1.read()
File "C:\Documents and Settings\M01091\Desktop\New Folder\psseraw.py", line 338, in read
if( int(K) == 0):
ValueError: invalid literal for int(): 250.000
>>>

The error is correct, but it should never get to this point, because I call the break command. But for whatever reason, it does not seem to want to break out of the for loop. Any ideas?? The class is below:

[PHP]class Transformer(Resource):
def read(self):
xfmrSubRecordCount = 0
nxfmrSubRecords = 0
xfmrSubRecords = []
key = ""
line = ""
count = 0

for line in self.file.xreadlines():
line = line.split("/") #Remove Comments
line = line[0]

if( line.strip() == "0"):
#End of Transformer Section
print "---BREAK---", line.strip()
print "WHY WON'T YOU BREAK"
print "count = " + str(count)
count = count + 1
break # WHY ISN'T IT BREAKING HERE???
elif( line.strip() == ""):
#Skip Blank Line
pass
else:
#Process Transformer Entry
if( xfmrSubRecordCount == 0):
#First Transformer Line
line = re.sub("\'.*?\'",replaceComa,line)
recordAttributes = line.split(",")
I = recordAttributes[0].strip()
J = recordAttributes[1].strip()
K = recordAttributes[2].strip()
CKT = recordAttributes[3].strip("'")
key = I+J+K+CKT.strip()
xfmrSubRecords.append(line)
xfmrSubRecordCount+=1

if( int(K) == 0):
#No Third Winding, hence Two Winding Transformer Record
nxfmrSubRecords = 4
else:
#Three Winding Transformer Record
nxfmrSubRecords = 5
del line[/PHP]
Aug 13 '07 #1
Share this Question
Share on Google+
1 Reply


P: 13
Nevermind, figured it out, was not a programming error, was just an error in the handling of my class. Thanks tho!
Aug 13 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.