My goal is to grab files with names ending with any item in ext. I have the following code:
ext=["n.log",".shm","rage"]
for filename1 in os.listdir(os.getcwd()):
if filename1.endswith(tuple(ext)):
src=os.getcwd()+'/'+filename1
irun_log=os.path.basename(src)
Running this code with Python 2.4, I get the following error:
Traceback (most recent call last):
File "./compile", line 141, in ?
if filename1.endswith(tuple(ext)):
TypeError: expected a character buffer object
Any help to figure out this issue is appreciated.
The ability to pass a tuple of strings to
str.endswith()to was introduced in Python 2.5: