Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.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.017 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'scripts': 0.03; 'sanity': 0.09; 'subject:Function': 0.09; 'subject:script': 0.09; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'locating': 0.16; 'path.': 0.16; 'files.': 0.16; 'wrote:': 0.18; 'directory.': 0.24; 'source': 0.25; 'gets': 0.27; 'header:In- Reply-To:1': 0.27; 'installed': 0.27; 'point': 0.28; 'chris': 0.29; 'am,': 0.29; 'unix': 0.29; 'message-id:@mail.gmail.com': 0.30; 'usually': 0.31; 'run': 0.32; 'subject:the': 0.34; 'common': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'belong': 0.36; 'view,': 0.36; 'done': 0.36; 'subject:?': 0.36; 'easiest': 0.38; 'to:addr:python-list': 0.38; 'files': 0.38; 'to:addr:python.org': 0.39; "you're": 0.61; 'programs,': 0.74; 'edwards': 0.91; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=dW6CUs+ukAlaWiE2pPg7cOuZo0eaY7ZJwXblHS+5ANQ=; b=ctLC2GzyVbdDJXR0CNWL7b4vYl/4q0SgPxVvV5Q5LHHPP1IZveiJMmoIJiMHpAevXa W7uTbUQJZfQaw2E8UBmdftRxaBBurvm6xrvoZ8a3o15lo9mN8UXZ3My4Yky0GwaXnIkx 3wjXcAs99cQsvUQPpiYo0efC+Eeu3uM5CcSuQoNdZ6JjjjcUIL+wYDz8HJca47PlQhF6 0M+4Z1qcs9kxz1Jz+5Xn8w52of+kO63inPsUc1Kax8E9UsT2z5TV2R61Uz/cafeh0RBv vZusXLk3DZghhzgZJHrBFmV9D78ejHFKICi89e7ZmdNEpQIMT/+bwxkpWhHE3Hy0MSvz 8vNA== MIME-Version: 1.0 X-Received: by 10.66.163.2 with SMTP id ye2mr2336732pab.170.1382972386420; Mon, 28 Oct 2013 07:59:46 -0700 (PDT) In-Reply-To: References: <00704f33-7e7f-4ccf-b28b-69776d2e237d@googlegroups.com> <526C7FEF.7020206@islandtraining.com> Date: Tue, 29 Oct 2013 01:59:46 +1100 Subject: Re: Function for the path of the script? From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: , Newsgroups: comp.lang.python Message-ID: Lines: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1382972391 news.xs4all.nl 15931 [2001:888:2000:d::a6]:37755 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:57834 On Tue, Oct 29, 2013 at 1:49 AM, Grant Edwards wrote: > On 2013-10-27, Chris Angelico wrote: >> It's very common to want to know what directory you're in - it's a >> good way to find data files. > > From a Unix point of view, that's also very wrong. Data files don't > belong in the same directory as the executable. For installed programs, maybe; but we run a lot of scripts out of source control, like a sanity checker that gets run immediately before a commit. Some of them need data files that are also source-managed, so we have them in the same directory. Locating those files is usually easiest done by tailing onto the script's path. ChrisA