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:\Documen ts and Settings\M01091 \Desktop\New Folder\tester.p y", line 72, in ?
TransformerReco rds1 = TransformerData 1.read()
File "C:\Documen ts 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(Res ource):
def read(self):
xfmrSubRecordCo unt = 0
nxfmrSubRecords = 0
xfmrSubRecords = []
key = ""
line = ""
count = 0
for line in self.file.xread lines():
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( xfmrSubRecordCo unt == 0):
#First Transformer Line
line = re.sub("\'.*?\' ",replaceComa,l ine)
recordAttribute s = line.split(",")
I = recordAttribute s[0].strip()
J = recordAttribute s[1].strip()
K = recordAttribute s[2].strip()
CKT = recordAttribute s[3].strip("'")
key = I+J+K+CKT.strip ()
xfmrSubRecords. append(line)
xfmrSubRecordCo unt+=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]