----- Original Message ----- From: "Tsang, Edward1" <e_tsang at trillium.com> Subject: RE: alny way of not using glob? > I was trying to get the script written under python 2.0 to work under 1.5.2. > > But I just discoverd that python1.5.2 that they installed is faulty and they > have no intention to reinstall it as not many peple use it ... Slobs. > Now instead of trying to get around getopt or glob.. I need to translate the > script to work with Python 1.5.2 .. > How to translate the following lines which uses Python 2.0 string operation > to ones that are understands by Python1.5.2??? > > Is the following fine? > [fromValue, toValue] = line.split(delimiter)[:2] > # Split line > replaced by: > [fromValue, toValue] = string.split(line,delimiter) Wouldn't this be more correct: fromValue, toValue = string.split(line,delimiter)[:2] I'm not sure why you would have [ ] on the lefthand side. > ....... > 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: if caseInsensitive: charMap[ord(string.upper(fromValue[0]))] = toValue charMap[ord(string.lower(fromValue[0]))] = toValue Note that ord() is supposed to be used on a string of one character. > # self.charMap = "".join(charMap) > replaced by: > self.charMap = string.join("",charMap) Backwards. Like this: self.charMap = string.join(charMap, "") > ............ > if not wholeWords: > # rePattern = '|'.join(map(re.escape, fromVals)) > replaced by: > rePattern = string.join('|', map(re.escape,fromVals)) Backwards again. Here: 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) --- ??? Backwards here also. Separator follows list to be joined. Also, the second line uses string.join incorrectly, when all you seem to want is simple string addition. From this: temp = string.join(map(re.escape,fromVals), '|') temp = temp + r')\b' rePattern = r'\b(' + temp I shrink to this: rePattern = r'\b(' + string.join(map(re.escape,fromVals), '|') + r')\b' > Tahnks You're welcome. Hey, answer a few questions for me if you will. What OS is on the webserver? If it is one for which there is a CGIPython build available, you could at least have a non-defective Python interpreter. CGIPython is a 1.5.2-based "distribution" of Python packed in a single executable, aimed specifically at web services which are too braindead to provide a (working?) Python interpreter. Find it at: http://www.lemburg.com/files/python/mxCGIPython.html
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4