how to map python 2.0 string opeartion to python 1.5.2 ?
ed_tsang at yahoo.com
ed_tsang at yahoo.com
Tue Apr 3 20:20:06 EDT 2001
Is there a way to map the following lines to 1.5.2?
I amusing 1.5.2 not the sys admin won;t upgrade to 2.0. I got a
scirpt written for 2.0 and try to port it back to 1.5.2 ..
Code:
[fromValue, toValue] = line.split(delimiter)[:2] #
Split line
replaced by:
[fromValue, toValue] = string.split(line,delimiter)
.......
No idea how to replace these lines with 1.5.2 syntax:
if caseInsensitive:
# charMap[ord(fromValue.upper())] = toValue
# charMap[ord(fromValue.lower())] = toValue
replaced by:
I don't know ...
# self.charMap = "".join(charMap)
replaced by:
self.charMap = string.join("",charMap)
............
if not wholeWords:
# rePattern = '|'.join(map(re.escape, fromVals))
replaced by:
rePattern = string.join('|', map(re.escape,fromVals))
else:
# rePattern = r'\b(' + '|'.join(map(re.escape, fromVals))
+ r')\b'
replaced by:
temp = string.join('|', map(re.escape,fromVals))
temp = string.join(temp,r')\b')
rePattern = string.join(r'\b(',temp) --- ???
Tahnks
More information about the Python-list
mailing list