[Python-ideas] maxsplit in os.path.split

Todd toddrjen at gmail.com
Mon Sep 28 13:46:36 CEST 2015

The "str.split" and "str.rsplit" methods have a useful "maxsplit" option,
which lets you set the number of times to split, defaulting to -1 (which is
"unlimited").  The corresponding "os.path.split", however, has no
"maxsplit" option.  It can only split once, which splits the last path
segment (the "basename") from the rest (equivalent of "str.rsplit" with

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".
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150928/a2167420/attachment.html>

More information about the Python-ideas mailing list