alny way of not using glob?

Tsang, Edward1 e_tsang at trillium.com
Tue Apr 3 20:16:43 EDT 2001


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 ...

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)

       .......
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
-----Original Message-----
From: Chris Gonnerman [mailto:chris.gonnerman at usa.net]
Sent: Tuesday, April 03, 2001 6:03 AM
To: edwardt at trillium.com
Cc: python-list at python.org
Subject: Re: alny way of not using glob?



----- Original Message ----- 
From: <edwardt at trillium.com>
Subject: alny way of not using glob?


> Hi I am trying to get a list of the files in the current direcoty by 
> using glob. But I have the following trouble:
> 1. glob is a standard module in python 2.0 but not 1.5.2 whihc I am 
> currently using and the sys admin has no intention to upgrade it ...

Actually glob is a standard module in 1.5.2... in fact it appears to be
pure Python, no C code at all.  I am attaching glob.py and fnmatch.py
from 1.5.2 for you to try out.

> 2. glob is unix dependent? My script needs to run in windows also ...

Nope.  I use it all the time on Windows.
 
> The code I am using is:
> targetFiles = reduce(operator.add, map(glob.glob, arguments[1:]))
> 
> value is arguments[1:] is "*.py"

Actually it's [ *.py" ], that is, a list of one item which is "*.py".

> when I print targetFile, it is:
> ['tp_tc_TNLC01.py', 'tp_tc_TNLC02.py', 'tp_tc_TNLC04.py', 'tp_tc_TNLC0
> 6.py', 'tp_tc_TNLC07.py', 'tp_tc_TNLC08.py', 'tp_tc_TNLC09.py', 'tp_tc
> _TNLC10.py', 'tp_tc_TNLC11.py', 'tp_tc_TNLC14.py', 'tp_tc_TNLC15.py', 
> 'tp_tc_TNLC16.py', 'tp_tc_TNLC17.py']

Is this not a correct list of filenames?
 
> How can I get around that??

What do you want it to do?







More information about the Python-list mailing list