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]