Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old September 4th, 2008, 02:35 PM
Francesco Guerrieri
Guest
 
Posts: n/a
Default Re: path slashes cleaning

On Thu, Sep 4, 2008 at 3:25 PM, Mathieu Prevot <mathieu.prevot@gmail.comwrote:
Quote:
Hi,
>
for scripts that take arguments, I would like to remove the trailing
slash if it's present.
>
Is there something else than:
>
a='/usr/local/lib/'
if a[-1] == '/':
a = list(a)
a.pop()
''.join(a)
>
Thanks,
Mathieu
a.rstrip('/') does the job.

bye,
Francesco
  #2  
Old September 4th, 2008, 05:05 PM
Jason Scheirer
Guest
 
Posts: n/a
Default Re: path slashes cleaning

On Sep 4, 6:32*am, "Francesco Guerrieri" <f.guerri...@gmail.com>
wrote:
Quote:
On Thu, Sep 4, 2008 at 3:25 PM, Mathieu Prevot <mathieu.pre...@gmail.com>wrote:
Quote:
Hi,
>
Quote:
for scripts that take arguments, I would like to remove the trailing
slash if it's present.
>
Quote:
Is there something else than:
>
Quote:
a='/usr/local/lib/'
if a[-1] == '/':
*a = list(a)
*a.pop()
*''.join(a)
>
Quote:
Thanks,
Mathieu
>
a.rstrip('/') does the job.
>
bye,
Francesco
[1]: import os.path
[2]: os.path.normpath('/usr/bin')
'/usr/bin'
[3]: os.path.normpath('/usr/bin/')
'/usr/bin'

And on windows:
[1]: import os.path
[2]: os.path.normpath(r'c:\data')
'c:\\data'
[3]: os.path.normpath('c:\\data\\')
'c:\\data'

Use the functions provided in os.path.
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles