Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: Question about imports and packages Date: Wed, 25 May 2016 18:34:14 +1000 Lines: 29 Message-ID: References: <85iny2agyr.fsf@benfinney.id.au> <574561e4$0$11112$c3e8da3@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de 7u4QSIe6Se554gw45reUowqQNBrY7DxnZuSK+MHPvGZg== 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; 'python,': 0.02; 'modify': 0.04; 'subject:Question': 0.05; '*not*': 0.07; 'cc:addr:python- list': 0.09; 'scripts': 0.09; 'scripting': 0.09; 'python': 0.10; ':-)': 0.12; 'wed,': 0.15; '+--': 0.16; '2016': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:74.125.82.46': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'shell': 0.18; 'runs': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; "aren't": 0.22; 'absolute': 0.23; 'second': 0.24; 'import': 0.24; 'header:In- Reply-To:1': 0.24; 'script': 0.25; 'equivalent': 0.27; 'message- id:@mail.gmail.com': 0.27; 'be:': 0.29; 'path,': 0.29; 'e.g.': 0.30; 'relative': 0.30; "i'd": 0.31; 'option': 0.31; 'run': 0.33; "d'aprano": 0.33; 'directory,': 0.33; 'steven': 0.33; 'languages': 0.34; 'handle': 0.34; 'received:google.com': 0.35; 'path': 0.35; 'something': 0.35; 'received:74.125.82': 0.35; "isn't": 0.35; 'but': 0.36; 'possible.': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'say': 0.37; 'names': 0.38; 'files': 0.38; 'where': 0.40; 'some': 0.40; 'temporarily': 0.61; 'different': 0.63; 'obvious': 0.76; 'chrisa': 0.84; 'to:none': 0.91; 'you).': 0.95 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:cc; bh=cDcowtO0yDBgeKJQjqWnsKwoctQprTS1URRzvDbia/o=; b=ZhjH/KlPYi/3GvH1g3LRgw2QGDW490aznLajqrT05RscnAWGOW5FEpiyPIe6L7PJhC Pns0Fw2ru7dORsoJhwJFVwfLxK5fP8Nk83ckzxEi1a6uuIxw24IER+R06fF/56QJRKe4 NW+LTQvc8YeNS2z8/bH1KT6v10QGtgDvFtYOqRPr59Yc0nrhU1WSxi20ofEqOml9Qd8N Rc+0qoH2hADOIXUSrNGMxQfuaBkkW9n96+f64fQyHvNuwOuhEi9/zYzrjjEXzX9LAqHc wSu8JR5+ewj0fka+cDozIB8qRb3PD7nEYb2WLXuil4e5CDjhJ4LIwEoMX0F45pdC8UF+ b9Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc; bh=cDcowtO0yDBgeKJQjqWnsKwoctQprTS1URRzvDbia/o=; b=cQYUXZTxAXxuDETlOzB1TKJ3cl/88qxLk0DfJAdNbjDV6AeGXC5O+GJqSTDscx8FlS NwcJAZEJi+xn6ClC3oGZlMVT9OyJ16yp0oP61UrWQUnpy6/ZCeNIJlSVLyVjbzfMF7Fo ypH8ULMa2kQfj3/JXbMgN7w/32Tw9qw71QmjyyrgNPBsl/Rj4WVEPgvcleJhimHus/D2 2rCN2e50RuXGDgf37kmJ/hLJrS774wDf5QKRmXh0kadsMWpDkAxxV3Rv7keERuENAptd LyNyCCsKvqsjdVQ1Aj2U/IYilQVy7KtQ9SWLSaqLU5+SvWnZEf1BfhlQk5jE0omvcv9i FvlA== X-Gm-Message-State: ALyK8tKS3rOgDbs1pFa/yzRAM8dkoLSCFTHlJ9x2THvjgQk7RhItTmswNo5diAWCYEEBnJ0DX+Dqsaao9QuSjg== X-Received: by 10.194.91.194 with SMTP id cg2mr2571915wjb.47.1464165254526; Wed, 25 May 2016 01:34:14 -0700 (PDT) In-Reply-To: <574561e4$0$11112$c3e8da3@news.astraweb.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <85iny2agyr.fsf@benfinney.id.au> <574561e4$0$11112$c3e8da3@news.astraweb.com> Xref: csiph.com comp.lang.python:109106 On Wed, May 25, 2016 at 6:27 PM, Steven D'Aprano wrote: > I don't think this is that much different from the way other scripting > languages handle it. E.g. bash. If I have a set of (say) shell scripts: > > fnord/ > +-- foo.sh > +-- bar.sh > > > where foo.sh runs bar.sh, but fnord is *not* on the PATH, the way you make it > work is: > > - have foo.sh temporarily modify the PATH; > - have foo.sh call bar.sh using an absolute pathname. > > That second option isn't available to Python, but then, .pth files aren't > available to the shell :-) The one obvious way with shell scripts is a *relative* pathname. You can say "./bar.sh" (or, if you want to run something relative to the script directory, some manipulation of path names and $0 will do that for you). The best Python equivalent would be: from . import bar I'd very much like for that to be possible. ChrisA