[Tutor] Simple Regex

Alan Gauld alan.gauld at yahoo.co.uk
Thu Apr 8 18:56:18 EDT 2021


On 08/04/2021 22:23, Mats Wichmann wrote:

> Maybe you can work with this:
> 
> 
>  >>> from pathlib import PureWindowsPath
>  >>> p = 
> PureWindowsPath(r'C:\Users\user\Downloads\4324234534254325\4324234534254325_213.csv')
>  >>> p.parts
> ('C:\\', 'Users', 'user', 'Downloads', '4324234534254325', 
> '4324234534254325_213.csv')
>  >>> p.parent
> PureWindowsPath('C:/Users/user/Downloads/4324234534254325')
>  >>> p.name
> '4324234534254325_213.csv'
>  >>>

Looks like I need to spend some time with pathlib.
The last time I looked at it (Python 3.3?) it was only marked
as a candidate for the standard lib and subject to change,
so I looked no further. I assume by now its a fixture?


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list