Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'tuple': 0.09; 'pathname': 0.16; 'received:173.11': 0.16; 'subject:list': 0.16; 'header:In-Reply- To:1': 0.22; "skip:' 30": 0.29; 'components,': 0.30; 'list': 0.32; 'to:addr:python-list': 0.34; 'header:X-Complaints-To:1': 0.34; 'header:User-Agent:1': 0.34; 'function.': 0.35; 'subject: ?': 0.35; 'but': 0.37; 'received:org': 0.38; 'subject:: ': 0.38; 'header:Mime-Version:1': 0.39; "there's": 0.39; 'to:addr:python.org': 0.39; "i'd": 0.40; 'subject:skip:o 10': 0.84; '-->': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Emile van Sebille Subject: Re: list comprehension to do os.path.split_all ? Date: Thu, 28 Jul 2011 14:15:57 -0700 References: <1954d20a-7177-45d9-afa0-e98b171b2822@w27g2000yqk.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 173-11-108-137-sfba.hfc.comcastbusiness.net User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20110624 Thunderbird/5.0 In-Reply-To: <1954d20a-7177-45d9-afa0-e98b171b2822@w27g2000yqk.googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1311887790 news.xs4all.nl 23896 [2001:888:2000:d::a6]:57357 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:10481 On 7/28/2011 1:18 PM gry said... > [python 2.7] I have a (linux) pathname that I'd like to split > completely into a list of components, e.g.: > '/home/gyoung/hacks/pathhack/foo.py' --> ['home', 'gyoung', > 'hacks', 'pathhack', 'foo.py'] > > os.path.split gives me a tuple of dirname,basename, but there's no > os.path.split_all function. > Why not just split? '/home/gyoung/hacks/pathhack/foo.py'.split(os.sep) Emile