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


Groups > comp.lang.python > #80912

Re: What does this line of code mean?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!bcyclone04.am1.xlned.com!bcyclone04.am1.xlned.com!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.027
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; '16,': 0.03; 'subject:code': 0.07; 'os.path': 0.09; 'empty.': 0.16; 'ignoring': 0.16; 'wrote:': 0.18; 'module': 0.19; 'split': 0.19; '>>>': 0.22; 'import': 0.22; 'extension': 0.26; 'code:': 0.26; 'header:In- Reply-To:1': 0.27; 'function': 0.29; 'message-id:@mail.gmail.com': 0.30; 'end,': 0.31; 'received:google.com': 0.35; 'ext': 0.36; 'subject:?': 0.36; 'skip:o 20': 0.38; 'nov': 0.38; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'explain': 0.39; 'to:addr:python.org': 0.39; 'skip:o 30': 0.61; 'kindly': 0.61; 'subject:this': 0.83; "'test'": 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=N51e+/OBQqLyotOix5xoP4cIglb/asPG7MEiflcD88k=; b=o8KuSDAla3CWNoAQ1LCH8PAE4ylFp/Sx91/+wRh/SgfsviRElzlyRTjVnjhyr9Ze7h 1j/7pjmLXp5A+5vazSMZ9Kj5xriWPiIimMQMIiwpAJ/YVpFWCZFIhNCb2Gt+2YvU5Dhr DiGcINEaYJowlcFQajWnLqJOHCHBKkGc4UWBheFkrLs786EV7HDYeIV+Iy1acUyEQr9p nx1AIeciVYe6xfRD3QDRNHNX7dprJzKsV7DT5dwgd72jfcX6vZYuyOQf3m8psUwAtP1K V0zzdrBwPmOROavUhZXZlwrS+PS8Fn/ABRWq6BJJrJmeO9uFc1m67NH5/JBmbrY2RGHy iS9A==
X-Received by 10.70.44.174 with SMTP id f14mr25705605pdm.38.1416174825249; Sun, 16 Nov 2014 13:53:45 -0800 (PST)
MIME-Version 1.0
In-Reply-To <CAA+hu4X4sP=B9ffkos5iY22UGzvmAT=_fvpR2Nuna5nst4FwWA@mail.gmail.com>
References <CAA+hu4X4sP=B9ffkos5iY22UGzvmAT=_fvpR2Nuna5nst4FwWA@mail.gmail.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Sun, 16 Nov 2014 14:53:04 -0700
Subject Re: What does this line of code mean?
To Python <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.15908.1416174834.18130.python-list@python.org> (permalink)
Lines 23
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1416174834 news.xs4all.nl 2935 [2001:888:2000:d::a6]:52572
X-Complaints-To abuse@xs4all.nl
X-Received-Bytes 3595
X-Received-Body-CRC 815498786
Xref csiph.com comp.lang.python:80912

Show key headers only | View raw


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 comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: What does this line of code mean? Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-16 14:53 -0700

csiph-web