-
-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-35183: Add typical examples to os.path.splitext docs #27286
Changes from 1 commit
116040e
9c906b6
cd772f9
a4f13d8
06c0cae
3156838
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -485,9 +485,17 @@ the :mod:`glob` module.) | |
|
||
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, e.g. ``splitext('bar')`` returns ``('bar', '')`` and | ||
``splitext('foo.bar.exe')`` returns ``('foo.bar', '.exe')``. Leading periods on the | ||
basename are ignored; ``splitext('.cshrc')`` returns ``('.cshrc', '')``. | ||
period. | ||
|
||
If the path contains no extension, ``ext`` will be ``''``. | ||
e.g. ``splitext('bar')`` returns ``('bar', '')`` | ||
|
||
If the path contains an extension, then ``ext`` will be set to this extension, | ||
including the leading period. Note that previous periods will be ignored. | ||
e.g. ``splitext('foo.bar.exe')`` returns ``('foo.bar', '.exe')``. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What you've done absolutely does accurately follow the style and patterns seen in this documentation thus far. I think it would be nice to do repr examples like this, though: If the path contains no extension, *ext* will be an empty string::
>>> splitpath('bar')
('bar', '')
If the path contains an extension, then *ext* will be set to this extension,
including the leading period. Note that previous periods will be ignored::
>>> splittext('foo.bar.exe')
('foo.bar', 'ext')
Leading periods on the basename are also ignored::
>>> splitext('.cshrc')
('.cshrc', '') BUT
So, I'd recommend just wait and see if / how others react to this comment, and only go ahead and restructure it like this if others agree with me, because might not! |
||
|
||
Leading periods on the basename are ignored. | ||
e.g. ``splitext('.cshrc')`` returns ``('.cshrc', '')``. | ||
|
||
.. versionchanged:: 3.6 | ||
Accepts a :term:`path-like object`. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is nitpicky (sorry). Note that up here in the prior docs, "ext" is italicized, then you switch to monospace. In general, throughout python documentation, you'll see italics used when referencing arguments or variable names in the midst of prose. I suggest changing "ext" on lines 490 and 493 to italics to match the style from the first paragraph.