Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #80911

Re: What does this line of code mean?

Date 2014-11-16 15:53 -0600
From Tim Chase <python.list@tim.thechases.com>
Subject Re: What does this line of code mean?
References <CAA+hu4X4sP=B9ffkos5iY22UGzvmAT=_fvpR2Nuna5nst4FwWA@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.15907.1416174686.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 2014-11-16 22:45, Abdul Abdul 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?

Have you tried them?

https://docs.python.org/2/library/os.path.html#os.path.splitext

This takes a path and splits it into everything-but-the-extension,
and the extension.  The "[0]" takes the first part (without the
extension), and the "+ '.jpg'" part tacks on that extension.

So it changes whatever the existing extension is to .jpg

-tkc

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: What does this line of code mean? Tim Chase <python.list@tim.thechases.com> - 2014-11-16 15:53 -0600

csiph-web