Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > python path separator

Reply
Thread Tools

python path separator

 
 
swapnil
Guest
Posts: n/a
 
      09-02-2010
I could not find any documentation for variables os.path.sep and
os.path.altsep. Although the first is pretty straightforward can
anyone explain the purpose of the second variable? Is it even useful?
According to issue http://bugs.python.org/issue709428, os.path.altsep
was 'None' till a long time and it didn't bother anyone?
 
Reply With Quote
 
 
 
 
Vlastimil Brom
Guest
Posts: n/a
 
      09-02-2010
2010/9/2 swapnil <>:
> I could not find any documentation for variables os.path.sep and
> os.path.altsep. Although the first is pretty straightforward can
> anyone explain the purpose of the second variable? Is it even useful?
> According to issue http://bugs.python.org/issue709428, os.path.altsep
> was 'None' till a long time and it didn't bother anyone?
> --
> http://mail.python.org/mailman/listinfo/python-list
>

see
http://docs.python.org/library/os.html#os.sep
http://docs.python.org/library/os.html#os.altsep

On windows it returns a slash
>>> os.altsep

'/'
which is often easier to use (i.e. if I understand correctly, in most
usual cases the forward slash should probably just work on most of the
recent OSes).

vbr
 
Reply With Quote
 
 
 
 
swapnil
Guest
Posts: n/a
 
      09-02-2010
On Sep 2, 12:25*pm, Vlastimil Brom <vlastimil.b...@gmail.com> wrote:
> 2010/9/2 swapnil <swapnil...@gmail.com>:> I could not find any documentation for variables os.path.sep and
> > os.path.altsep. Although the first is pretty straightforward can
> > anyone explain the purpose of the second variable? Is it even useful?
> > According to issuehttp://bugs.python.org/issue709428, os.path.altsep
> > was 'None' till a long time and it didn't bother anyone?
> > --
> >http://mail.python.org/mailman/listinfo/python-list

>
> seehttp://docs.python.org/library/os.html#os.sephttp://docs.python.org/library/os.html#os.altsep
>
> On windows it returns a slash>>> os.altsep
>
> '/'
> which is often easier to use (i.e. if I understand correctly, in most
> usual cases the forward slash should probably just work on most of the
> recent OSes).
>
> * *vbr


Thanks for help
 
Reply With Quote
 
Nobody
Guest
Posts: n/a
 
      09-02-2010
On Wed, 01 Sep 2010 23:57:21 -0700, swapnil wrote:

> I could not find any documentation for variables os.path.sep and
> os.path.altsep. Although the first is pretty straightforward can
> anyone explain the purpose of the second variable? Is it even useful?


The purpose is so that you can do e.g.:

if c == os.path.sep or c == os.path.altsep:
...

On Windows, both '\' and '/' are directory separators; you shouldn't rely
upon a particular one being used, but should check for either.

 
Reply With Quote
 
 
 
Reply

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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Separator in $PATH Stefano Mioli Ruby 3 10-20-2010 08:35 AM
File-Find skips directories with spaces depending on path separator on Windows Matt Garrish Perl Misc 9 01-17-2006 02:12 PM
Path Separator and Windows Justin Johnson Ruby 19 12-30-2005 06:36 PM
When did Windows start accepting forward slash as a path separator? Stephen Ferg Python 30 09-30-2003 04:22 AM
RE: When did Windows start accepting forward slash as a path separator? Tony Meyer Python 1 09-26-2003 02:22 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57