On Fri, 29 Aug 2008 14:46:53 -0400, Derek Martin wrote:
> On Fri, Aug 29, 2008 at 07:28:40PM +0100, [EMAIL PROTECTED] wrote:
>> dirListFinal = []
>> for item in dirList:
>> print item
>> if item.endswith('\\') == True:
>
> if item[-1] == '\\':
Which will fail badly if item is the empty string.
Rajat, rather than trying to invent your own code to join directory
paths, you should use the os.path module:
>>> import os
>>> os.path.join('/dir', 'x', 'y', 'z', 'file.txt')
'/dir/x/y/z/file.txt'
>>> os.path.split('/a/b/c/d/file.txt')
('/a/b/c/d', 'file.txt')
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list