Unnormalizing normalized path in Windows

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Julien

    Unnormalizing normalized path in Windows

    Hi,

    In Windows, when a path has been normalized with os.path.normpat h, you
    get something like this:

    C:/temp/my_dir/bla.txt # With forward slashes instead or backward
    slashes.

    Is it possible to revert that?
    >>magic_functio n('C:/temp/my_dir/bla.txt')
    'C:\temp\my_dir \bla.txt'

    I wonder if there's a standard function to do that...

    Thanks a lot!

    Julien
  • Duncan Booth

    #2
    Re: Unnormalizing normalized path in Windows

    Julien <jphalip@gmail. comwrote:
    In Windows, when a path has been normalized with os.path.normpat h, you
    get something like this:
    >
    C:/temp/my_dir/bla.txt # With forward slashes instead or backward
    slashes.
    >
    Is it possible to revert that?
    >
    >>>magic_functi on('C:/temp/my_dir/bla.txt')
    'C:\temp\my_dir \bla.txt'
    >
    I wonder if there's a standard function to do that...
    Yes, it's called os.path.normpat h. Did you actually try it before posting?
    >>print os.path.normpat h('C:/temp/my_dir/bla.txt')
    C:\temp\my_dir\ bla.txt

    Comment

    Working...