Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #80912 > unrolled thread
| Started by | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| First post | 2014-11-16 14:53 -0700 |
| Last post | 2014-11-16 14:53 -0700 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: What does this line of code mean? Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-16 14:53 -0700
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2014-11-16 14:53 -0700 |
| Subject | Re: What does this line of code mean? |
| Message-ID | <mailman.15908.1416174834.18130.python-list@python.org> |
On Sun, Nov 16, 2014 at 2:45 PM, Abdul Abdul <abdul.sw84@gmail.com> wrote:
> I just came across the following line of code:
>
> outputfile = os.path.splitext(infile)[0] + ".jpg"
>
> Can you kindly explain to me what those parts mean?
>>> import os.path
>>> help(os.path.splitext)
Help on function splitext in module ntpath:
splitext(p)
Split the extension from a pathname.
Extension is everything from the last dot to the end, ignoring
leading dots. Returns "(root, ext)"; ext may be empty.
>>> os.path.splitext('test.txt')
('test', '.txt')
>>> os.path.splitext('test.txt')[0]
'test'
>>> os.path.splitext('test.txt')[0] + ".jpg"
'test.jpg'
Back to top | Article view | comp.lang.python
csiph-web