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


Groups > comp.lang.python > #106692

Re: Python programs and relative imports

From Rob Gaddi <rgaddi@highlandtechnology.invalid>
Newsgroups comp.lang.python
Subject Re: Python programs and relative imports
Date 2016-04-08 16:59 +0000
Organization A noiseless patient Spider
Message-ID <ne8o2e$van$1@dont-email.me> (permalink)
References <ndu70d$m0t$1@dont-email.me>

Show all headers | View raw


Rob Gaddi wrote:

> Does anyone know the history of why relative imports are only available
> for packages and not for "programs"?  It certainly complicates life.
>

Really, no one?  It seems like a fairly obvious thing to have included;
all of the reasons that you want to be explicit in saying:

  from . import mypkg

in a package apply just as well in an executable script.  But instead,
they've got different semantics such that you expressly _cannot_ use
relative imports in a script.  This feels like such a glaring oversight
that there must have been some rationale behind it.

-- 
Rob Gaddi, Highland Technology -- www.highlandtechnology.com

Email address domain is currently out of order.  See above to fix.

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


Thread

Python programs and relative imports Rob Gaddi <rgaddi@highlandtechnology.invalid> - 2016-04-04 17:07 +0000
  Re: Python programs and relative imports Rob Gaddi <rgaddi@highlandtechnology.invalid> - 2016-04-08 16:59 +0000
    Re: Python programs and relative imports Chris Angelico <rosuav@gmail.com> - 2016-04-09 03:11 +1000
      Re: Python programs and relative imports Rob Gaddi <rgaddi@highlandtechnology.invalid> - 2016-04-08 17:50 +0000
        Re: Python programs and relative imports Chris Angelico <rosuav@gmail.com> - 2016-04-09 04:04 +1000
        Re: Python programs and relative imports Ian Kelly <ian.g.kelly@gmail.com> - 2016-04-08 12:26 -0600

csiph-web