Filepath string manipulation help

Steve Holden steve at holdenweb.com
Thu Nov 3 13:43:35 EST 2005


mjakowlew wrote:
>  I got the "IE Fix" working, here's the code:
> 
> ____________________________
> path = r'c:\here\there\files\file.ext'
> 
> i=len(path)
> j=0
> size=len(path)
> 
> while i:
>   i=i-1
>   if path[i]== '\\':
>     j=i+1
>     break
> 
> filename = path[j:size]
> print "FILENAME: %s" %(filename)
> _______________________________
> 
> Most importantly this works on my Zope webserver.
> 
> Thanks again,
> mjakowlew
> 
Is there some reason for preferring this to the fully portable

import os
print os.path.basename(filepath)

that Robert Dowell suggested in immediate response to your post?

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC                     www.holdenweb.com
PyCon TX 2006                  www.python.org/pycon/




More information about the Python-list mailing list