[ python-Bugs-1115886 ] os.path.splitext don't handle unix hidden file correctly
SourceForge.net
noreply at sourceforge.net
Sun Dec 4 15:44:04 CET 2005
Bugs item #1115886, was opened at 2005-02-04 01:27
Message generated for change (Comment added) made by jjlee
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1115886&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Jeong-Min Lee (falsetru)
Assigned to: Nobody/Anonymous (nobody)
Summary: os.path.splitext don't handle unix hidden file correctly
Initial Comment:
I expected this.
>>> os.path.splitext('/path/to/.Hiddenfile')
('/path/to/.Hiddenfile', '')
but got this.
>>> os.path.splitext('/path/to/.Hiddenfile')
('/path/to/', '.Hiddenfile')
----------------------------------------------------------------------
Comment By: John J Lee (jjlee)
Date: 2005-12-04 14:44
Message:
Logged In: YES
user_id=261020
-1
I hate to be a stick-in-the-mud, but the existing behaviour
is what I would expect, and seems to be regular -- always
picks the last dot:
>>> os.path.splitext('a/b/c/foo.bar')
('a/b/c/foo', '.bar')
>>> os.path.splitext('a/b/c/f.oo.bar')
('a/b/c/f.oo', '.bar')
>>> os.path.splitext('a/b/c/.foo')
('a/b/c/', '.foo')
>>> os.path.splitext('a/b/c/.foo.txt')
('a/b/c/.foo', '.txt')
Changing it would surely break somebody's code too, of course.
----------------------------------------------------------------------
Comment By: Reinhold Birkenfeld (birkenfeld)
Date: 2005-06-18 22:05
Message:
Logged In: YES
user_id=1188172
Interestingly, altering the behaviour of splitext in such a
way does not contradict the documentation, which is:
"""
Split the pathname path into a pair (root, ext) such that
root + ext == path, and ext is empty or begins with a period
and contains at most one period.
"""
Personally I'm in favour of this change (on Unix it makes
sense, while on Windows you can hardly find an
"extension-only" file).
----------------------------------------------------------------------
Comment By: engelbert gruber (grubert)
Date: 2005-06-13 15:12
Message:
Logged In: YES
user_id=147070
from test_posixpath.py ::
self.assertEqual(posixpath.splitext(".ext"), ("", ".ext"))
IMHO should then return (".ext",""). if this is desired ::
if i<=p.rfind('/'):
return p, ''
else:
return p[:i], p[i:]
should do
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1115886&group_id=5470
More information about the Python-bugs-list
mailing list