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
I think it would be useful if "os.path.split" also had a "maxsplit"
On 28 September 2015 at 12:46, Todd
wrote: 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@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
-- --Guido van Rossum (python.org/~guido)