472,119 Members | 1,632 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Help with Break Command

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
1 2353
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.

Similar topics

31 posts views Thread by da Vinci | last post: by
15 posts views Thread by Buck Rogers | last post: by
7 posts views Thread by tyler_durden | last post: by
3 posts views Thread by Matthew Warren | last post: by
2 posts views Thread by jhhbr549 | last post: by
2 posts views Thread by rookiejavadude | last post: by

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.