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


Groups > comp.lang.python > #109106

Re: Question about imports and packages

From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: Question about imports and packages
Date 2016-05-25 18:34 +1000
Message-ID <mailman.79.1464165255.20402.python-list@python.org> (permalink)
References <CAPxRSnb=nEEjR63iNRJyepXo+aG6d+U7H2k5E_FbedC35tcsZQ@mail.gmail.com> <85iny2agyr.fsf@benfinney.id.au> <mailman.77.1464151220.20402.python-list@python.org> <574561e4$0$11112$c3e8da3@news.astraweb.com> <CAPTjJmopdBhUDeyzpMNYWNYAjA=JL_cnyRKSyz=DAT8gdhc7xw@mail.gmail.com>

Show all headers | View raw


On Wed, May 25, 2016 at 6:27 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> 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

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


Thread

Re: Question about imports and packages Ben Finney <ben+python@benfinney.id.au> - 2016-05-25 14:39 +1000
  Re: Question about imports and packages Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-05-25 18:27 +1000
    Re: Question about imports and packages Chris Angelico <rosuav@gmail.com> - 2016-05-25 18:34 +1000

csiph-web