Possible bug in string handling (with kludgy work-around)
Charles Hixson
charleshixsn at earthlink.net
Mon Dec 26 17:23:03 EST 2011
This doesn't cause a crash, but rather incorrect results.
self.wordList = ["The", "quick", "brown", "fox", "carefully",
"jumps", "over", "the", "lazy", "dog", "as", "it",
"stealthily", "wends", "its", "way", "homewards", '\b.']
for i in range (len (self.wordList) ):
if not isinstance(self.wordList[i], str):
self.wordList = ""
elif self.wordList[i] != "" and self.wordList[i][0] == "\b":
print ("0: wordList[", i, "] = \"", self.wordList[i], "\"", sep
= "")
print ("0a: wordList[", i, "][1] = \"", self.wordList[i][1],
"\"", sep = "")
tmp = self.wordList[i][1] ## !! Kludge --
remove tmp to see the error
self.wordList[i] = tmp + self.wordList[i][1:-1] ## !!
Kludge -- remove tmp + to see the error
print ("1: wordList[", i, "] = \"", self.wordList[i], "\"", sep
= "")
print ("len(wordList[", i, "]) = ", len(self.wordList[i]) )
--
Charles Hixson
More information about the Python-list
mailing list