On Fri, Aug 29, 2008 at 8:37 PM, Steven D'Aprano
<[EMAIL PROTECTED]> wrote:
> 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
>
Steven, Thanks so much.
I just found out that I unknowingly searching for something else i.e.
/ rather than \
Just corrected this mistake and fixed it.


-- 
Regrads,
Rajat
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to