From: Tutor <tutor-bounces+sjeik_appie=hotmail....@python.org> on behalf of
Alan Gauld via Tutor <tutor@python.org>
Sent: Thursday, November 8, 2018 10:49 AM
To: tutor@python.org
Subject: Re: [Tutor] Regex for Filesystem path (Asad)
On 08/11/2018 02:55, Asad wrote:
> Why is it putting \ this breaks the unix path it should be:
>
> /a/b/c/d/test/28163133/22326541 ===> for unix platform logs
>
> \a\b\c\d\test\28163133\22326541 ===> for windows platform logs
Hi,
Maybe pathlib will be of use here:
>>> from pathlib import Path
>>> Path('c:\\beeh/foo\\bar/baz').as_posix()
'c:/beeh/foo/bar/baz'
I was thinking it would also be possible to do (in Windows):
import os.path
os.path.sep = '/'
os.path.normpath('c:\\beeh/foo\\bar/baz')
But alas, this still creates normalized windows-style paths.
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor