Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!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.001 X-Spam-Evidence: '*H*': 1.00; '*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; 'bieber': 0.16; 'declaimed': 0.16; 'email addr:ix.netcom.com': 0.16; 'email name:wlfraed': 0.16; 'from:addr:ix.netcom.com': 0.16; 'from:addr:wlfraed': 0.16; 'from:name:dennis lee bieber': 0.16; 'received:66.245': 0.16; 'received:dsl.mindspring.com': 0.16; 'received:mindspring.com': 0.16; 'received:wlfraed': 0.16; 'url:netcom': 0.16; 'url:wlfraed': 0.16; 'windows:': 0.16; 'wulfraed': 0.16; '>>>': 0.16; 'subject:list': 0.16; "doesn't": 0.22; 'url:home': 0.25; 'skip:[ 10': 0.26; 'lee': 0.28; 'thu,': 0.28; 'kelly': 0.30; 'to:addr :python-list': 0.34; 'header:X-Complaints-To:1': 0.34; 'subject: ?': 0.35; 'charset:us-ascii': 0.36; 'skip:o 20': 0.36; 'using': 0.37; 'received:org': 0.38; 'subject:: ': 0.38; 'header:Mime- Version:1': 0.39; 'to:addr:python.org': 0.39; 'skip:r 20': 0.40; 'dennis': 0.77; 'fine...': 0.84; 'subject:skip:o 10': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: list comprehension to do os.path.split_all ? Date: Thu, 28 Jul 2011 21:15:50 -0700 Organization: > Bestiaria Support Staff < References: <1954d20a-7177-45d9-afa0-e98b171b2822@w27g2000yqk.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: user-11fa7d5.dsl.mindspring.com X-Newsreader: Forte Agent 3.3/32.846 X-No-Archive: YES 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1311912962 news.xs4all.nl 23843 [2001:888:2000:d::a6]:37251 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:10498 On Thu, 28 Jul 2011 15:31:43 -0600, Ian Kelly declaimed the following in gmane.comp.python.general: > Using os.sep doesn't make it cross-platform. On Windows: > > >>> os.path.split(r'C:\windows') > ('C:\\', 'windows') > >>> os.path.split(r'C:/windows') > ('C:/', 'windows') > >>> r'C:\windows'.split(os.sep) > ['C:', 'windows'] > >>> r'C:/windows'.split(os.sep) > ['C:/windows'] Fine... So normpath it first... >>> os.path.normpath(r'C:/windows').split(os.sep) ['C:', 'windows'] >>> -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/