Unnormalizing normalized path in Windows

Duncan Booth duncan.booth at invalid.invalid
Sun Jun 29 16:13:30 CEST 2008


Julien <jphalip at gmail.com> wrote:

> In Windows, when a path has been normalized with os.path.normpath, 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_function('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.normpath. Did you actually try it before posting?

>>> print os.path.normpath('C:/temp/my_dir/bla.txt')
C:\temp\my_dir\bla.txt



More information about the Python-list mailing list