[Python-ideas] maxsplit in os.path.split
Guido van Rossum
guido at python.org
Mon Sep 28 16:12:09 CEST 2015
Also, the similarity between str.*split() and os.path.split() is not close
enough to draw conclusions about one from the other.
On Mon, Sep 28, 2015 at 4:58 AM, Paul Moore <p.f.moore at gmail.com> wrote:
> On 28 September 2015 at 12:46, Todd <toddrjen at gmail.com> wrote:
> > I think it would be useful if "os.path.split" also had a "maxsplit"
> option.
> > This would default to "1" (the current behavior"), but could be set to
> any
> > value allowed by "str.split". Using this option would follow the
> behavior
> > of "str.rsplit" for that value of "maxsplit".
>
> In Python 3.6+ (which is the only place a change like this is likely
> to happen) you're probably better using pathlib. There, you can use
> path.parts, which returns a tuple of the path elements, so you can do
> things like
>
> >>> Path('C:\\what\\ever\\you\\like.txt').parts[-3:]
> ('ever', 'you', 'like.txt')
>
> That's usable now in Python 3.4+, and a backport is available at
> https://pypi.python.org/pypi/pathlib/
>
> Paul
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
--
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150928/d8a39dca/attachment.html>
More information about the Python-ideas
mailing list