Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'skip:/ 10': 0.07; 'versions.': 0.07; 'python': 0.09; 'friday,': 0.09; 'portable': 0.09; 'splitting': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; 'subject:which': 0.16; 'wrote:': 0.17; 'url:dev': 0.17; 'variable': 0.20; 'equivalent': 0.20; 'not,': 0.21; "i'd": 0.22; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'linux': 0.24; 'command': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'older': 0.27; 'environment': 0.29; 'subject:like': 0.29; 'function': 0.30; 'code': 0.31; 'implement': 0.32; 'url:python': 0.32; 'anybody': 0.32; 'function.': 0.33; 'received:google.com': 0.34; 'thanks': 0.34; 'received:209.85': 0.35; 'there': 0.35; 'url:org': 0.36; 'url:library': 0.36; 'should': 0.36; 'subject: (': 0.36; 'does': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'url:docs': 0.38; 'gelonida': 0.84 Newsgroups: comp.lang.python Date: Sat, 22 Sep 2012 20:55:46 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=122.167.215.13; posting-account=uPFZNQoAAAAm9w7z13q1SjWNKNjztdcD References: User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 122.167.215.13 MIME-Version: 1.0 Subject: Re: portable way of locating an executable (like which) From: Ramchandra Apte To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1348372549 news.xs4all.nl 6841 [2001:888:2000:d::a6]:48715 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:29782 On Friday, 21 September 2012 02:37:01 UTC+5:30, gelonida wrote: > I'd like to implement the equivalent functionality of the unix command > > /usr/bin/which > > > > The function should work under Linux and under windows. > > > > Did anybody already implement such a function. > > If not, is there a portable way of splitting the environment variable PATH? > > > > Thanks for any sugestions shutil.which does this in Python 3.3: http://docs.python.org/dev/library/shutil.html#shutil.which You can copy the code to support older Python versions.