This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author r.david.murray
Recipients amaury.forgeotdarc, nidoizo, nnorwitz, r.david.murray, rhettinger
Date 2009-07-03.18:00:04
SpamBayes Score 3.6708414e-11
Marked as misclassified No
Message-id <1246644006.59.0.506860939227.issue894936@psf.upfronthosting.co.za>
In-reply-to
Content
I think the OP meant os.path.split, not str.split, but I don't
understand what incompatibility he is referring to.  This seems to work
fine:

>>> ntpath.join(*ntpath.split("Z:/xyz"))
'Z:/xyz'

That said, I'd like to note that I was surprised the first few times I
used os.path.split to find that it did only one split.  I fully expected
it to be symetric with os.path.join and analogous to str.split and give
me a list of path components.

After thinking about this for a while, I think there are enough
subleties involved in doing this operation that it would be worth having
a cannonical function to do it the "right way" (which, IMO, is not how
the proposed patch does it!)

Here is what I think it should produce:

  D:/abc\\xyz.ext   -->    ['D:\\', 'abc', 'xyz.ext']
  D:abc/xyz.ext     -->    ['D:', 'abc', 'xyz.ext']
  
I don't think this is what the OP is expecting, but I think it is
necessary to keep the drive attached to the first path element to avoid
ambiguity and to be consistent with the rest of the os.path semantics.

The reason I think this is worth doing is that otherwise what one would
do to produce the list of path components would be something like:

  drive, rpath = splitdrive(normpath("D:/abc/def.ext"))
  pathcomponents = rpath.split(sep)

which produces the result:

   ['', 'abc', 'def.ext']

when what one really wants is:

   ['\\', 'abc', 'def.ext']

Yes, your code can treat '' as indicating an absolute path, but that
adds one more step to the mutlistep process, the omission of any one of
which leads to subtle bugs.  Better to have a function that does it right.

Now, the question is, are there enough real use cases for this function
to motivate someone to do the work to add it?  I don't have any myself.
History
Date User Action Args
2009-07-03 18:00:07r.david.murraysetrecipients: + r.david.murray, nnorwitz, rhettinger, amaury.forgeotdarc, nidoizo
2009-07-03 18:00:06r.david.murraysetmessageid: <1246644006.59.0.506860939227.issue894936@psf.upfronthosting.co.za>
2009-07-03 18:00:05r.david.murraylinkissue894936 messages
2009-07-03 18:00:04r.david.murraycreate