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


Groups > comp.lang.python > #10557

Re: list comprehension to do os.path.split_all ?

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!post.news.xs4all.nl!not-for-mail
Return-Path <michael.poeltl@univie.ac.at>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.017
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'think,': 0.05; 'skip:[ 30': 0.09; ';-)': 0.12; 'wrote:': 0.15; 'already.': 0.16; 'bieber': 0.16; 'mean,': 0.16; 'received:131': 0.16; 'suggested.': 0.16; 'univ.': 0.16; 'wien,': 0.16; '>>>': 0.16; 'subject:list': 0.16; 'part,': 0.19; 'this?': 0.22; "doesn't": 0.22; 'header:In- Reply-To:1': 0.22; 'wonder': 0.23; '(or': 0.25; 'handles': 0.25; 'function': 0.26; 'url:mailman': 0.27; 'lee': 0.28; "skip:' 30": 0.29; 'fixed': 0.29; 'carl': 0.30; 'url:listinfo': 0.32; 'michael': 0.32; 'list': 0.32; 'break': 0.33; 'to:addr:python- list': 0.34; 'header:User-Agent:1': 0.34; 'there': 0.34; 'subject: ?': 0.35; "isn't": 0.35; 'charset:us-ascii': 0.36; 'url:python': 0.37; 'url:org': 0.38; 'subject:: ': 0.38; 'something': 0.38; 'should': 0.39; 'to:addr:python.org': 0.39; 'might': 0.39; 'where': 0.40; 'skip:+ 10': 0.66; 'here.': 0.66; 'materials': 0.69; 'dennis': 0.77; 'no?': 0.84; 'subject:skip:o 10': 0.84; 'voice:': 0.84
DKIM-Signature v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=univie.ac.at; s=rev2; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:To:From:Date; bh=HUwH3PbHNpR7ws2AAczFwk+x5Kcd5Iyq7vhGMJ29NAQ=; b=AhIzBp+AeqE3jsZDmEW8OnBqHBhJbrBljRP0YptIhEpdjjqrQz0P3uR8q40INskNzA9tyq+pj8tIY2HDK9NTJxbRgj282cuGcXMw1ioA1Ge3hy/89ZAcmfgDgPxYZQVL9JnrE1XsyXkgVJzj3UPm4vP24tyX/cytdEUS9JLJzl0=;
Date Sat, 30 Jul 2011 02:23:15 +0200
From Michael Poeltl <michael.poeltl@univie.ac.at>
To python-list@python.org
Subject Re: list comprehension to do os.path.split_all ?
References <1954d20a-7177-45d9-afa0-e98b171b2822@w27g2000yqk.googlegroups.com> <j0sjig$5dj$1@dough.gmane.org> <mailman.1595.1311888735.1164.python-list@python.org> <879a920c-d06a-4413-9566-6c9f0b737235@glegroupsg2000goo.googlegroups.com> <4E33169E.90307@web.de>
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
In-Reply-To <4E33169E.90307@web.de>
User-Agent Mutt/1.5.18 (2008-05-17)
X-Univie-Virus-Scan scanned by ClamAV on justin.univie.ac.at
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1645.1311985785.1164.python-list@python.org> (permalink)
Lines 37
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1311985785 news.xs4all.nl 23982 [2001:888:2000:d::a6]:43365
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:10557

Show key headers only | View raw


* Alexander Kapps <alex.kapps@web.de> [2011-07-29 22:30]:
> On 29.07.2011 21:30, Carl Banks wrote:
>
>> It's not even fullproof on Unix.
>>
>> '/home//h1122/bin///ghi/'.split('/')
>>
>> ['','home','','bin','','','ghi','']
what about this?                                                                
>>> ' '.join('/home//h1122/bin///ghi/'.split('/')).split()                      
['home', 'h1122', 'bin', 'ghi']                                                 
>>>                                                                             
;-)                                                                             
regards                                                                         
Michael

>> Carl Banks
>
> This would also be fixed with normpath() as Dennis Lee Bieber suggested. 
> And my solution with list comprehensions handles this too.
>
> Still, there might be other path oddities which would break here. I  
> think, that something like a split_all() function should be available in 
> the stdlib, no?
>
> Actually, it isn't the first time, where I wonder why os.path.split() 
> doesn't do this already. I mean, str.split() doesn't only split on the 
> first part, right?
> -- 
> http://mail.python.org/mailman/listinfo/python-list
>

-- 
Michael Poeltl
Computational Materials Physics      voice: +43-1-4277-51409
Univ. Wien, Sensengasse 8/12         fax:   +43-1-4277-9514 (or 9513) 
A-1090 Wien, AUSTRIA   cmp.mpi.univie.ac.at 

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


Thread

list comprehension to do os.path.split_all ? gry <georgeryoung@gmail.com> - 2011-07-28 13:18 -0700
  Re: list comprehension to do os.path.split_all ? Stefaan Himpe <stefaan.himpe@gmail.com> - 2011-07-28 22:32 +0200
  Re: list comprehension to do os.path.split_all ? Neil Cerutti <neilc@norwich.edu> - 2011-07-28 20:36 +0000
    Re: list comprehension to do os.path.split_all ? Ethan Furman <ethan@stoneleaf.us> - 2011-07-28 14:03 -0700
  Re: list comprehension to do os.path.split_all ? Alan Meyer <ameyer2@yahoo.com> - 2011-07-28 16:40 -0400
    Re: list comprehension to do os.path.split_all ? TheSaint <no@nowhere.net.no> - 2011-07-29 22:29 +0800
  Re: list comprehension to do os.path.split_all ? Ian Kelly <ian.g.kelly@gmail.com> - 2011-07-28 14:44 -0600
  Re: list comprehension to do os.path.split_all ? Ian Kelly <ian.g.kelly@gmail.com> - 2011-07-28 14:47 -0600
  Re: list comprehension to do os.path.split_all ? Ian Kelly <ian.g.kelly@gmail.com> - 2011-07-28 15:04 -0600
  Re: list comprehension to do os.path.split_all ? Alexander Kapps <alex.kapps@web.de> - 2011-07-28 23:06 +0200
  Re: list comprehension to do os.path.split_all ? Emile van Sebille <emile@fenx.com> - 2011-07-28 14:15 -0700
  Re: list comprehension to do os.path.split_all ? Ian Kelly <ian.g.kelly@gmail.com> - 2011-07-28 15:31 -0600
    Re: list comprehension to do os.path.split_all ? Carl Banks <pavlovevidence@gmail.com> - 2011-07-29 12:30 -0700
      Re: list comprehension to do os.path.split_all ? Alexander Kapps <alex.kapps@web.de> - 2011-07-29 22:22 +0200
      Re: list comprehension to do os.path.split_all ? Michael Poeltl <michael.poeltl@univie.ac.at> - 2011-07-30 02:23 +0200
      Re: list comprehension to do os.path.split_all ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-07-30 10:55 +1000
      Re: list comprehension to do os.path.split_all ? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-07-29 22:17 -0700
      Re: list comprehension to do os.path.split_all ? Michael Poeltl <michael.poeltl@univie.ac.at> - 2011-07-31 07:40 +0200
  Re: list comprehension to do os.path.split_all ? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-07-28 21:15 -0700
    Re: list comprehension to do os.path.split_all ? Neil Cerutti <neilc@norwich.edu> - 2011-07-29 12:40 +0000
      Re: list comprehension to do os.path.split_all ? Hrvoje Niksic <hniksic@xemacs.org> - 2011-07-31 08:42 +0200

csiph-web